Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If the user is typing in a form field while an update to the app state comes

Could you give a practical example of what you mean here? I can't quite wrap my head around what kind of interaction you're describing.

Do you mean some kind of scenario like a shared document with multiple people editing it? This is a very niche case.

> This means when the DOM resets, there's no problem with elements getting removed and added back in,

Could you give a practical example of this? I've been building web apps for a long time and I don't know what "when the dom resets" means.



The problem described by antris is that, if a developer were to naively tear down and rebuild the entire DOM tree on each state change, the browser would discard some important state which belongs to the old DOM nodes. This state includes the text selection, keyboard focus, mouse capture, scroll position, and the progress of CSS transitions and animations.

React solves this problem by building a virtual DOM, and then conservatively updating the actual DOM (sometimes just mutating individual HTML attributes!) so that this state is preserved.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: