? React Final Form Listeners is a collection of useful components for listening to fields in a ? React Final Form.
npm install --save react-final-form-listeners react-final-form final-formor
yarn add react-final-form-listeners react-final-form final-formimport { 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>
)}
/>
)ExternallyChanged
name : Stringchildren: (externallyChanged: boolean) => React.NodeOnBlur
name : Stringchildren: () => voidOnChange
name : Stringchildren: (value: any, previous: any) => voidOnFocus
name : Stringchildren: () => voidThe following can be imported from react-final-form-listeners.
ExternallyChangedRenders is render prop with a boolean flag when the specified field was last updated externally (changed while not active).
name : StringThe name of the field to listen to.
children: (externallyChanged: boolean) => React.NodeA render prop given the boolean flag.
OnChangeCalls its children callback whenever the specified field changes. It renders nothing.
name : StringThe name of the field to listen to.
children: (value: any, previous: any) => voidA function that will be called whenever the specified field is changed. It is passed the new value and the previous value.
OnFocusCalls its children callback whenever the specified field becomes active. It renders nothing.
name : StringThe name of the field to listen to.
children: () => voidA function that will be called whenever the specified field is changed. It is passed the new value and the previous value.
OnBlurCalls its children callback whenever the specified field is blurred. It renders nothing.
name : StringThe name of the field to listen to.
children: () => voidA function that will be called whenever the specified field is blurred.