[英]Why is this component switching from controlled to uncontrolled? - React
這是我的無狀態反應組件:
export default ({acresMin, update}) => (
<div>
<input
onChange={(e) => update({'acresMin': e.target.value})}
placeholder="10"
type="text"
value={acresMin}/>
</div>
)
當我更改input
的值時,我收到此warning
:
Warning: StatelessComponent 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.
我正在使用onChange
更新並保存通過props
填充的store
的值。
我怎么不理解這個?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.