search

Home  >  Q&A  >  body text

node.js - antdesign的Input控件加了初始化值,网站控制台暴警告,什么原因?


这句话爆了警告

即:Warning: Input is changing an uncontrolled input of type text 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: https://fb.me/react-controlle...
如果,我在initailValue传入不变的量string,就不会暴警告

为什么 呢?

巴扎黑巴扎黑2776 days ago724

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-17 14:47:12

    I also have this problem, because it’s just a warning, not an error, and it doesn’t affect development, so I don’t care

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 14:47:12

    The last link in the error you reported mentioned: A controlled <input> has a value prop. In your code, the value attribute does not appear.

    Putting the execution result of a function into input is personally undesirable. You should save the execution result of this function in a variable in advance, and then put the variable into input, just like formItemLayout. I think this is better

    reply
    0
  • Cancelreply