这句话爆了警告
即: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,就不会暴警告
为什么 呢?
我也有這樣的問題,因為只是warn不是error不影響開發就沒管
你報的錯最後的那個連結中,有提到:A controlled has a value prop。而在你的程式碼中,並沒有出現value屬性。
而你將一個函數執行結果放入input中的作法,個人覺得不可取。你應事先以一個變數儲存此函數的執行結果,再將變數放入input中,就如formItemLayout一樣,我覺得這樣比較好