Skip to content

Latest commit

 

History

History
11 lines (7 loc) · 563 Bytes

component-changing-uncontrolled-to-be-controlled.md

File metadata and controls

11 lines (7 loc) · 563 Bytes

Saw this warning in console:

Warning: A component 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.

solution:

value={this.state.fields.name || ''}   // (undefined || '') = ''

reason: stackoverflow question