-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TextField] Fix controlled input warning in React 15 #4047
Comments
@maticrivo Please review your use of the input -- this is not a material-ui issue |
@maticrivo more info: facebook/react#5864 React DOM now warns if an input switches between being controlled and uncontrolled. |
Is this going to be fixed in 2.0 or do we need a fix before that is done? |
it would be nice to have it fixed |
Mmmm... any ideas on how avoid it? Am I doing something wrong?
|
@abelosorio I also faced this just now. Seems that here's how things should be done in the new API: <TextField
value={ value }
- onChange={ handleValueChange }
+ InputProps={{
+ onChange: handleValueChange,
+ }}
/> |
Thanks @kachkaev, I'll try it. |
I'd like to get this fixed to, I have the same issue, but I do not understand @abelosorio soution, could you explain more? |
Hi @stevematdavies. I wrote that code in a project where I'm not working anymore. I can't remember exactly how I fixed that, but the problem (as I remember) was in using Anyway, my comment was not a suggested solution but only the code where I got the warning message. |
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.
|
@rsweeney21 exactly! I changed my initial state in Redux for two Selects from
to
where This warning then disappears. |
Problem Description
I'm getting this error after upgrading to React 15 and MUI 0.15.0-beta.1
Versions
The text was updated successfully, but these errors were encountered: