- ตอบสนองผู้ฟังในรูปแบบสุดท้ายคือคอลเลกชันของส่วนประกอบที่มีประโยชน์สำหรับการฟังฟิลด์ใน A? ตอบสนองแบบฟอร์มสุดท้าย
npm install --save react-final-form-listeners react-final-form final-formหรือ
yarn add react-final-form-listeners react-final-form final-form import { Form , Field } from 'react-final-form'
import { OnChange } from 'react-final-form-listeners'
const MyForm = ( ) => (
< Form
onSubmit = { onSubmit }
render = { ( { handleSubmit , pristine , invalid } ) => (
< form onSubmit = { handleSubmit } >
< div >
< label >
< Field name = "foo" component = "input" type = "checkbox" /> Turn foo on?
</ label >
< OnChange name = "foo" >
{ ( value , previous ) => {
// do something
} }
</ OnChange >
</ div >
...
</ form >
) }
/>
) ExternallyChangedname : Stringchildren: (externallyChanged: boolean) => React.NodeOnBlurname : Stringchildren: () => voidOnChangename : Stringchildren: (value: any, previous: any) => voidOnFocusname : Stringchildren: () => void ต่อไปนี้สามารถนำเข้าจาก react-final-form-listeners
ExternallyChanged การแสดงผลคือการแสดงผล Prop ด้วยธง boolean เมื่อฟิลด์ที่ระบุได้รับการอัปเดตล่าสุดจากภายนอก (เปลี่ยนในขณะที่ไม่ได้ใช้งาน)
name : Stringชื่อของฟิลด์ที่จะฟัง
children: (externallyChanged: boolean) => React.Nodeเสาเรนเดอร์ที่ได้รับธงบูลีน
OnChange โทรกลับ children เมื่อใดก็ตามที่มีการเปลี่ยนแปลงฟิลด์ที่ระบุ มันไม่มีอะไรเลย
name : Stringชื่อของฟิลด์ที่จะฟัง
children: (value: any, previous: any) => voidฟังก์ชั่นที่จะถูกเรียกเมื่อใดก็ตามที่มีการเปลี่ยนแปลงฟิลด์ที่ระบุ มันผ่านค่าใหม่และค่าก่อนหน้า
OnFocus โทรกลับ children เมื่อใดก็ตามที่ฟิลด์ที่ระบุจะทำงาน มันไม่มีอะไรเลย
name : Stringชื่อของฟิลด์ที่จะฟัง
children: () => voidฟังก์ชั่นที่จะถูกเรียกเมื่อใดก็ตามที่มีการเปลี่ยนแปลงฟิลด์ที่ระบุ มันผ่านค่าใหม่และค่าก่อนหน้า
OnBlur โทรกลับ children เมื่อใดก็ตามที่ฟิลด์ที่ระบุเบลอ มันไม่มีอะไรเลย
name : Stringชื่อของฟิลด์ที่จะฟัง
children: () => voidฟังก์ชั่นที่จะถูกเรียกเมื่อใดก็ตามที่ฟิลด์ที่ระบุเบลอ