Text inputs are manipulated multiple times (and unnecessarily) in the DOM
See original GitHub issueSteps to reproduce:
I created a JS Bin to reproduce the problem.
http://jsbin.com/qegiwuzara/edit?html,js,console,output
- Type
Perf.start()
into the console (third pane from the left). - Edit the contents of one of the text inputs in the rightmost pane.
- Type
Perf.stop()
andPerf.printDOM()
into the console.
This should show that the value
attribute of the edited text input was updated three times in the DOM, and the unedited text input was also updated once.
I tested the same code with 0.13.1. According to React.addons.Perf, only the modified input was updated in the DOM, and it was only updated once.
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Direct DOM manipulations are expensive. | by Abhijit Hycinth
Multiple DOM changes. Each DOM modification will trigger a reflow. Be it adding a new element, changing the value or various attributes of...
Read more >Manipulating documents - Learn web development | MDN
This is usually done by using the Document Object Model (DOM), ... Set the text content of the span to the input element...
Read more >The Basics of DOM Manipulation in Vanilla JavaScript (No ...
Sebastian Seitz gives you a crash course in DOM manipulation with vanilla JavaScript, abstracting the more verbose parts into a set of ...
Read more >jQuery/Javascript - How to wait for manipulated DOM to ...
I had to wait for jQuery to manipulate the DOM and then grap the changes (load form fields multiple times into a form,...
Read more >Manipulating DOM Elements With React Hook useRef()
The inputRef holds the reference to the DOM element input , and all properties of the element can be accessed directly through the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
With the current implementation, the
value
property on an input element is only updated if the value has changed. This goes for the other managed attributes as well. That means thatReactDOMInput.updateWrapper
will not update the DOM if there are no updates to be made, so this should no longer be an issue.Thanks!
I also came across on this behavior while testing my app with Perf tools (0.14.2, 0.14.3). React updates text inputs (type “update attribute”) on every refresh despite the fact that the value has not changed. Any progress / planned changes?