-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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
Bug: <input> value never updated in unit test #5934
Comments
That's expected behaviour, read the controlled components docs for a better explanation https://facebook.github.io/react/docs/forms.html |
Apologies, I thought you meant the value was hard coded rather than inserted via state |
Cool, I just re-read Controlled Components and was about to say "aren't I doing the same thing?" 😄 |
React does not guarantee to change the markup. As long as the rendered value within the input box is correct (ie. what the user sees is correct), then React is doing its job correctly. The markup is irrelevant. FWIW, this behavior will probably be closer to what you want when #5680 merges. |
To clarify what @jimfb is saying - When React updates |
Say I have a component that renders an
<input type="text" value="whatever">
. If I try to unit test it usingReactTestUtils.Simulate.change
, the component gets the updated value but then thevalue
attribute in the DOM doesn't get the update.See https://jsfiddle.net/c1ht6zwm/3/
The text was updated successfully, but these errors were encountered: