form icon indicating copy to clipboard operation
form copied to clipboard

React 16.3 warning

Open super918180 opened this issue 6 years ago • 4 comments

I use rc-ffrm in React 16.3, and get warning as this: A component is changing an uncontrolled input of type undefined 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-controlled-components

super918180 avatar Jun 22 '18 11:06 super918180

Could you reproduce your issue on https://codesandebox.io?

yesmeck avatar Jun 23 '18 12:06 yesmeck

Reproduced with the demo in the README.md

https://codesandbox.io/s/xzj4npj4k4

Official demos have the same issue

http://react-component.github.io/form/examples/across-router.html#/

Just enter a value into an input and the warning appears

marklawlor avatar Jul 15 '18 11:07 marklawlor

Just set initialValue for the input.

benjycui avatar Jul 16 '18 07:07 benjycui

But I'd like the value in the form to an have undefined value, as the field is optional

For my use case I have a number field that is optional, but if the user selects a value it must be >0. If I set the initialValue to undefined I get the same error, and if I set it to "" (which the react warnings say you should if you want it to be empty) the number field's value is a string.

marklawlor avatar Jul 16 '18 10:07 marklawlor