Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React - Ignore subnodes

Is there a way to stop react from removing/changing nodes embedded in a react component.

For example, I have a react component that acts as a container for a non-react component that manages its DOM on its own. Is there a way to mark such components for reactjs, so that it does not modify its DOM?

In my case, I want my react component to be inline-editable by CKeditor, but react always removes/destroys the editor and all the nodes it has added to the DOM, because they were not defined in the react component itself and so it thinks that those elements should not be there.

Any ideas?

like image 446
Van Coding Avatar asked Jul 21 '14 12:07

Van Coding


1 Answers

If you return false from a shouldComponentUpdate method on your component, then React will step out of the way and the entire reconciliation process will be skipped for that subtree. Of course, this means that you need to manage all DOM mutations yourself in that area and can't take advantage of React.

like image 75
Sophie Alpert Avatar answered Sep 19 '22 13:09

Sophie Alpert