`

Warning: `value` prop on `input` should not be null.

阅读更多

 

// console报错信息如下
Warning: `value` prop on `input` should not be null. Consider using the empty string to clear the component or `undefined` for uncontrolled components.
    in input (created by AddAddress)
    in div (created by AddAddress)
    in div (created by AddAddress)
    in AddAddress (created by RouterContext)
    in div (created by Unknown)
    in div (created by Unknown)
    in Unknown (created by RouterContext)
    in RouterContext (created by Router)
    in Router

 

 

原因解析:

由于input需要设置value,而初始化state里面的value值为null,导致react解析报Waring。

Warning: `value` prop on `input` should not be null. Consider using the empty string to clear the component or `undefined` for uncontrolled components.

 

解决方案:

1、waring忽略不管

2、设置input初始化值位空字符串

<input type="number" maxLength="6" placeholder="选填" value={postcode || ''} />

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics