Reactjs 如何修复“不建议使用不安全的组件在严格模式下安装,这可能表明代码中存在错误。”?
我在react项目中使用redux表单,这是一个应用程序组件,它初始化了redux表单:Reactjs 如何修复“不建议使用不安全的组件在严格模式下安装,这可能表明代码中存在错误。”?,reactjs,redux,redux-form,Reactjs,Redux,Redux Form,我在react项目中使用redux表单,这是一个应用程序组件,它初始化了redux表单: import { Field, reduxForm } from 'redux-form'; const onSubmit = (values) => { alert(JSON.stringify(values)); }; function App(props) { return ( <div className="App"> &l
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);
如何修复此错误?关于此问题,似乎存在一个尚未解决的问题。你应该等待redux表单的作者发布一个更新,或者寻找一个替代库(因为这个表单的作者似乎说在大多数情况下你不应该使用它)——apokryfos似乎对此存在争议。您应该等待
redux form
的作者发布更新,或者寻找一个替代库(因为这个库的作者似乎说在大多数情况下您不应该使用它),您正在使用react吗?如果是,请尝试异步
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)