React - 忽略子节点 [英] React - Ignore subnodes
问题描述
例如,我有一个反应组件,作为一个容器,作为一个容器一个不反应的组件,它自己管理它的DOM。有没有办法标记这样的组件为reactjs,以便它不修改其DOM?
在我的情况下,我希望我的反应组件是内联可编辑的CKeditor,但是反应总是会删除/破坏编辑器及其添加到DOM的所有节点,因为它们没有在反应组件本身中定义,因此它认为这些元素不应该存在。
任何想法?
如果您返回 false
从您的组件的一个 shouldComponentUpdate
方法,然后React将逐步走出来,该子树将跳过整个对帐过程。当然,这意味着您需要自己管理所有DOM突变,并且无法利用React。
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?
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.
这篇关于React - 忽略子节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!