How can I fix `Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code.`?
I'm using redux forms in react project and this is the app component which has redux forms intialized :
import { Field, reduxForm } from 'redux-form';
const onSubmit = (values) => {
alert(JSON.stringify(values));
};
function App(props) {
return (
<div className="App">
<form onSubmit={props.handleSubmit}>
<div>
<label htmlFor="firstName">First Name</label>
<Field name="firstName" component="input" type="text" />
</div>
<div>
<label htmlFor="lastName">Last Name</label>
<Field name="lastName" component="input" type="text" />
</div>
<div>
<label htmlFor="email">Email</label>
<Field name="email" component="input" type="email" />
</div>
<button type="submit">Submit</button>
</form>
{props.number}
<button onClick={() => props.callAction()} />
</div>
);
}
App = reduxForm({
form: 'contact',
onSubmit
})(App);
But I get this error in the console which is coming from react strict mode :
Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code.
* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at:state
Please update the following components: Field, Form(App)
How can I fix this error ?
As apokryfos commented, there seems to be an open issue about this. I should either wait for the authors of redux-form to release an update or seek an alternative library (because the author of this one seems to say that we shouldn't be using it in most cases).