3

I am getting this issue with react form. After entering or deleting values from input field I get a red warning in the console. If I comment out the validate prop everything works fine.

Warning: Cannot update a component from inside the function body of a different component.

import { Field, reduxForm } from 'redux-form'; const required = value => (value ? undefined : 'Required field') const renderField = ({ input, label, type, meta: { touched, error, warning } }) => ( <div> <label>{label}</label> <div> <input {...input} placeholder={label} type={type} /> {touched && ((error && <span>{error}</span>) || (warning && <span>{warning}</span>))} </div> </div> ) function LoginForm(props) { const { handleSubmit } = props; return ( <form onSubmit={handleSubmit} > {console.log("LOGIN FORM PROPS", props)} <Field label="Username" name="username" component={renderField} type="text" placeholder="username" validate={[required]} /> <Field label="Password" name="password" component={renderField} type="password" placeholder="password" validate={[required]} /> <button type='submit'>Submit</button> </form> ) } export default reduxForm({ form: 'loginForm' })(LoginForm) 
2

1 Answer 1

1

Update react and react-dom version 16.13.1, it's removed the warning
more detail find here -> https://github.com/redux-form/redux-form/issues/4619

after updating the react and react-dom version if the warning is still there then there is a two case

Case 1
its becuse of react-hot-loader. so, replace react-hot-loader with @pmmmwh/react-refresh-webpack-plugin in webpack.config.js

Case 2
It's because of @hot-loader/react-dom, @hot-loader/react-dom is still on version 16.13.0, it's not compatible with [email protected], so, replace @hot-loader/react-dom alias in webpack.config.js like below example

webpack.config.js

//replace @hot-loader/react-dom with react-dom only ... resolve: { alias: { 'react-dom': 'react-dom', }, } ... 
Sign up to request clarification or add additional context in comments.

2 Comments

I'm still seeing @hot-loader/react-dom latest version is 16.13.0
@KwiZ Yes, it's my mistake, I removed the updated answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.