question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextField] Fix controlled input warning in React 15

See original GitHub issue

Problem Description

I’m getting this error after upgrading to React 15 and MUI 0.15.0-beta.1

TextField is changing a uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa)

Versions

  • Material-UI: 0.15.0-beta.1
  • React: 15.0.1
  • Browser: Google Chrome Canary (Version 52.0.2712.0 canary (64-bit))

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

24reactions
rsweeney21commented, Jan 21, 2018

In React 15+, you will get a warning if you change the value prop of an input from undefined (uncontrolled) to a non-null value (controlled). If you are seeing this warning, then it’s probably because you are not initializing value in your component state to an empty string.

constructor(props) {
    super(props);
    this.state = {value: ''};
}

render() {
    return (<TextField value={this.state.value} onChange={this.handleChange} />);
}
1reaction
stiofandcommented, Dec 11, 2017

I’d like to get this fixed to, I have the same issue, but I do not understand @abelosorio soution, could you explain more?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[TextField] Fix controlled input warning in React 15 · Issue #4047
In React 15+, you will get a warning if you change the value prop of an input from undefined (uncontrolled) to a non-null...
Read more >
Warning: TextField is changing a controlled input of type text ...
The solution for the issue is to remove the value attribute in textfield component or put null value in value attribute of component....
Read more >
A component is changing an uncontrolled input to be controlled
The warning "A component is changing an uncontrolled input to be controlled" occurs when an input value is initialized to `undefined` but is...
Read more >
a component is changing a controlled input to be uncontrolled ...
"Warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a...
Read more >
A component is changing an uncontrolled input to be controlled
A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found