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
When a form is updated with new props which contain a new onChange callback, the previous onChange callback will be called instead, if the validated formData doesn't deep equal the new formData. This causes problems if onChange is a closure containing important data that changed inbetween.
Steps to Reproduce
Create a form with an onChange callback in the props
Update the form (same key) with a new onChange callback in the props
UNSAFE_componentWillReceiveProps(nextProps){constnextState=this.getStateFromProps(nextProps,nextProps.formData);if(!deepEquals(nextState.formData,nextProps.formData)&&!deepEquals(nextState.formData,this.state.formData)&&this.props.onChange// should be nextProps.onChange){this.props.onChange(nextState);// should be nextProps.onChange}this.setState(nextState);}
Version
"react-jsonschema-form": "1.8.1"
The text was updated successfully, but these errors were encountered:
Prerequisites
Description
When a form is updated with new props which contain a new
onChange
callback, the previousonChange
callback will be called instead, if the validatedformData
doesn't deep equal the newformData
. This causes problems ifonChange
is a closure containing important data that changed inbetween.Steps to Reproduce
onChange
callback in the propsonChange
callback in the propsReduced Example:
Considering
someValue
is counting up like1
,2
etc. then the calls toonChange
will log1
,1
,2
,3
etc.Expected behavior
New
onChange
callback called.Actual behavior
Previous
onChange
callback called.The problem lies in Form.js#44:
Version
"react-jsonschema-form": "1.8.1"
The text was updated successfully, but these errors were encountered: