You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With v0.12, to stylize an input given its state (pending for example), you have to catch the events:
exportclassInputextendsReact.Component{[...]state: InputState={field: undefined};componentWillMount(){this.context.form.addFieldWillValidateEventListener(this.fieldWillValidate);this.context.form.addFieldDidValidateEventListener(this.fieldDidValidate);this.context.form.addFieldDidResetEventListener(this.fieldDidReset);}componentWillUnmount(){this.context.form.removeFieldWillValidateEventListener(this.fieldWillValidate);this.context.form.removeFieldDidValidateEventListener(this.fieldDidValidate);this.context.form.removeFieldDidResetEventListener(this.fieldDidReset);}fieldWillValidate=(fieldName: string)=>{// Ignore the event if it's not for usif(fieldName===this.props.name){this.setState({field: 'pending'});}};fieldDidValidate=(field: Field)=>{// Ignore the event if it's not for usif(field.name===this.props.name){this.setState({ field });}};fieldDidReset=(field: Field)=>{// Ignore the event if it's not for usif(field.name===this.props.name){this.setState({field: undefined});}};[...]}
There is probably a better story here thx to hooks.
With v0.12, to stylize an input given its state (pending for example), you have to catch the events:
There is probably a better story here thx to hooks.
See https://www.google.com/search?q=field+validation+status
Work on field lifecycle: untouched => willValidate => didValidate (hasErrors, hasWarnings, hasInfos, isValid) => didReset
Related issues: #40
We should also do the same for the form itself:
Work on form lifecycle: untouched => willValidate => didValidate (hasErrors, hasWarnings, hasInfos, isValid) => didReset
Check for inspiration here: https://github.com/bluebill1049/react-hook-form
The text was updated successfully, but these errors were encountered: