组件正在更改要在react中控制的电子邮件类型的非受控输入


index.js:1375 Warning: A component is changing an uncontrolled input of type email to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: 
in input (at userModal.js:57)
in div (at userModal.js:56)
in div (at userModal.js:55)
in div (at userModal.js:49)
in div (at userModal.js:47)
in form (at userModal.js:42)
in div (at userModal.js:41)
in div (at userModal.js:40)
in div (at userModal.js:39)
in div (at userModal.js:36)
in UserModal (created by ConnectFunction)
in ConnectFunction (at home.js:15)
in div (at home.js:12)
in div (at home.js:11)
in div (at home.js:10)
in Home (created by ConnectFunction)
in ConnectFunction (created by Context.Consumer)
in Route (at App.js:26)
in div (at Layout.jsx:20)
in Layout (created by ConnectFunction)
in ConnectFunction (at App.js:17)
in Router (created by BrowserRouter)
in BrowserRouter (at App.js:16)
in App (at src/index.js:30)
in Provider (at src/index.js:29)

控制台。@index.js:1375**强文本***强调文本*

请解释这一点。A组件正在更改要控制的电子邮件类型的不受控制的输入

很可能意味着输入的初始值是未定义的,然后您开始键入=>,从而设置值。给输入值一个初始状态,它应该被解析。

这可能意味着您没有onChange回调,但提供了value属性而不是defaultValue。因此,如果应该控制该输入,则提供onChange回调,如果不控制,则使用defaultValue而不是value

最新更新