react.js Warning: Failed form propType: You provided a value prop to a form field without an onChange handler. This will render a read-only field.

错误信息:

eact.js:20483 Warning: Failed form propType: You provided a value prop to a form field without an onChangehandler. This will render a read-only field. If the field should be mutable use defaultValue. Otherwise, set either onChange or readOnly. Check the render method of TickTock.

原因:

如果设置value,那value就永远是设置的那个值,要通过输入内容改变只能通过onChange,要么就把这个input设置成readOnly的

英文讲得很明白,如果你希望的是给字段赋初值那就用 defaultValue,如果用了类似 <input value={1} />这种,那这个输入框的值将永远为1,无法通过输入来更改,只能通过onChange来修改