React에서 커링은 함수에 대한 고급 기술입니다. 여러 매개변수를 받아 최종적으로 함수를 계속 반환하여 균일하게 처리하는 함수 인코딩 형식을 말합니다. 커링을 통해 양식을 처리할 때 양식 제어 데이터를 쉽게 얻을 수 있습니다.
이 튜토리얼의 운영 환경: Windows 10 시스템, 반응 버전 17.0.1, Dell G3 컴퓨터.
리액트 커링이란 무엇인가요?
함수 커링:
계속해서 함수 호출을 통해 함수를 반환하여 매개변수를 여러 번 받아들이고 최종적으로 이를 균일하게 처리하는 함수 인코딩 형식을 얻습니다. -순서 함수: 함수가 다음 두 가지 사양 중 하나를 충족하면 해당 함수는 고차 함수입니다
1. 함수가 매개변수를 함수로 받아들이면 해당 함수를 고차 함수라고 부를 수 있습니다2 . 함수 호출의 반환 값이 여전히 함수인 경우 a는 고차 함수라고 부를 수 있습니다.
3. 일반적인 고차 함수에는 promise, setTimeout, arr.map 등이 있습니다.예는 다음과 같습니다.
양식 양식에서 제어된 구성 요소를 사용하여 상태 데이터를 바인딩하여 클릭 시 양식 데이터를 표시합니다.
import React, {Component} from 'react'; export default class Form extends Component{ state = { userName: '', password: '' } submitForm = (event) => { event.preventDefault() //阻止表单提交 const {userName, password } = this.state; alert(`${userName}, ${password}`) } updateUserName = (event) => { this.setState({ userName: event.target.value, }) } updatePassword = (event) => { this.setState({ password: event.target.value, }) } render() { return ( <form onSubmit={this.submitForm}> 用户名:<input type="text" name="userName" onChange={this.updateUserName}/> 密码: <input type="password" name="password" onChange={this.updatePassword}/> <button>登录</button> </form> ) } }
보시다시피 이 방법은 양식 항목이 많을 때 더 번거롭고 커링 함수를 사용하여 최적화할 수 있습니다.
import React, {Component} from 'react'; export default class Form extends Component{ state = { userName: '', password: '' } submitForm = (event) => { event.preventDefault() //阻止表单提交 const {userName, password } = this.state; alert(`${userName}, ${password}`) } updateFormData = (key) => { return (event) => { this.setState({ [key]: event.target.value, }) } } render() { return ( <form onSubmit={this.submitForm}> 用户名:<input type="text" name="userName" onChange={this.updateFormData('userName')}/> 密码: <input type="password" name="password" onChange={this.updateFormData('password')}/> <button>登录</button> </form> ) } }
this.updateFormData()의 반환 값은 onChange 이벤트에 바인딩된 콜백 함수이며 매개변수는 이벤트입니다. 이런 방식으로 첫 번째 호출이 이루어질 때 유형이 전달되고, 변경 이벤트가 트리거될 때 값이 전달될 수 있습니다.
import React, {Component} from 'react'; export default class Form extends Component{ state = { userName: '', password: '' } submitForm = (event) => { event.preventDefault() //阻止表单提交 const {userName, password } = this.state; alert(`${userName}, ${password}`) } updateFormData = (key, event) => { this.setState({ [key]: event.target.value, }) } render() { return ( <form onSubmit={this.submitForm}> 用户名:<input type="text" name="userName" onChange={(event) => this.updateFormData('userName', event)}/> 密码: <input type="password" name="password" onChange={(event) => this.updateFormData('password', event)}/> <button>登录</button> </form> ) } }【관련 추천:
javascript 비디오 튜토리얼
,web front-end
】위 내용은 리액트 커링이 뭐야?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

클래스 선택기 및 ID 선택기의 사용은 특정 사용 사례에 따라 다릅니다. 1) 클래스 선택기는 다중 요소, 재사용 가능한 스타일에 적합하며 2) ID 선택기는 고유 한 요소 및 특정 스타일에 적합합니다. 클래스 선택기는 더 유연하며 ID 선택기는 처리하기가 더 빠르지 만 코드 유지 보수에 영향을 줄 수 있습니다.

TheKeyGoalSandMotivationSBehindhtml5WeretoEnhancesemanticstructure, EverneMultImediasupport, andensureBetTerferfortPerformanceAndCompatibilityAcrossDevices, DrivenBytheneedToaddresshtml4'SlimitationsAndModernWebDemands.1) HTMl5AIMEDTOMPROVETUCETUR

idsareUniqueAndusedForsingleElements, whileclassesareuseableforlultipleements.1) useidsforuniqueElementsLikeSpecificheader.2) USECLASSESFORCONSESTENTSTYLINGACROSSMultipleEmentements likeSlikeButtons

html5aimstoenhancewebaccessibility, Interactivity, andefficiency

html5isnotparticular indifficulttousebutreequiresunderstandingStandingStandingStandingStandingStandingStandingStandingStandingStandingStandingStandingS

아니요, 당신은 uplemultipleidsinthesamedom.1) idsmustbeuniqueperhtmlspecification, andusingduplicatescancauseSconsistentBrowserBehavior.2) useclassesforstylingmultipleelements, attributesectorscendats eftibutes 및 descenderfortrecture

html5aimstoenhancewebcapabilities, MakingItmoredynamic, Interactive, and Accessible.1) itsupportsmultimediaelementslikeand, 2) SemanticlementsImpreveAcessibilityandCodeReardability.3) 특징적인 부대, 응답 Whebappl

html5aimstoenhancewebdevelopmentandusereerexperiencetroughsemanticstructure, multimediaintegration 및 performanceimprovements


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

드림위버 CS6
시각적 웹 개발 도구

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경