Virtual DOM Questions

Asked 2 years ago, Updated 2 years ago, 49 views

If you operate DOM with jQuery, it will be different from the virtual DOM held by reactjs.If you do that, the difference will be reflected when rendering, and you can't help but feel that the operation you did with jQuery will disappear.
Is it okay?

javascript reactjs

2022-09-30 18:23

1 Answers

reactjs is not safe because it does not know that the DOM has been manipulated externally.

Conflicts with virtual DOMs can cause unexpected behavior, so you should be aware of the behavior of virtual DOMs when working with them from outside.

https://github.com/facebook/react/issues/3218#issuecomment-75513815

Mutation of DOM node attributes/properties is safe (but should be available). Mutation of the DOM node hierarchy for anything but insertion of nodes into empty leaves is disaster waiting to happyen.

Note: Changing the attributes and properties of a DOM node (from outside React) is safe (although it should be avoided).Any change in the hierarchical structure of any DOM node, with the exception of inserting a node into an empty end, can cause a catastrophe at any time.


2022-09-30 18:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.