؟ رد فعل المستمعين Final Form هي مجموعة من المكونات المفيدة للاستماع إلى الحقول في أ؟ رد فعل الشكل النهائي.
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 يتم تقديم Renders مع علامة 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وظيفة سيتم استدعاؤها عندما يكون الحقل المحدد غير واضح.