React-bootstrap: Warning: FormControl is changing

Created on 22 Sep 2016  路  3Comments  路  Source: react-bootstrap/react-bootstrap

I got a warning

warning.js?0260:36 Warning: FormControl 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-controlled-components

And I found a Formcontrol bring that warning

<FormControl 
  type="text"
    ref="accountName"
    placeholder="Account Name"
    value={_.get(this.props.user, 'account.name')}
    onChange={this.handleUpdate.bind(this, 'name')} />`

I realized if I use account.accountName instead of account.name for value
then warning disappear..
I just wonder the 'name' shouldn't be used props or state??
I can't tell it is a responsibility on react bootstrap or lodash actually..

Anybody have an idea..?

Most helpful comment

Your value is toggling between undefined and a defined value. This isn't a React-Bootstrap thing.

All 3 comments

Your value is toggling between undefined and a defined value. This isn't a React-Bootstrap thing.

@taion

Ok. and what do you suggest?
If there is no value initially, it is logically that it is undefined. Then it gets defined. Normal behavior. But throws warning. How to deal with it?

Set your initial value to an empty string. See the link in the warning from react

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tkram01 picture tkram01  路  3Comments

jquense picture jquense  路  3Comments

Shadowman4205 picture Shadowman4205  路  3Comments

ckiss picture ckiss  路  3Comments

m2mathew picture m2mathew  路  3Comments