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.

Text inputs are manipulated multiple times (and unnecessarily) in the DOM

See original GitHub issue

Steps to reproduce:

I created a JS Bin to reproduce the problem.

http://jsbin.com/qegiwuzara/edit?html,js,console,output

  1. Type Perf.start() into the console (third pane from the left).
  2. Edit the contents of one of the text inputs in the rightmost pane.
  3. Type Perf.stop() and Perf.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:closed
  • Created 8 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
awearycommented, Sep 20, 2017

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 that ReactDOMInput.updateWrapper will not update the DOM if there are no updates to be made, so this should no longer be an issue.

Thanks!

0reactions
karczkcommented, Dec 10, 2015

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?

Read more comments on GitHub >

github_iconTop 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 >

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