Failed to execute ‘removeChild‘ on ‘Node‘: The node to be removed is not a child of this node.

react中需要清空一些特殊的容器

Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

这个主要原因是因为没有傅容器唯一的key值,根据diff算法的原理,

解决方案

给容器添加唯一的标识 key={+new Date()}

<div key={+new Date()}>
					<VueWrapper
						component={DataFlowVue}
						updateNode={updateNode}
						nodesData={data}
						i18n={t}
						dataSourceType={dataSourceType}
					/>
				</div>

版权声明:本文为lixinhua_man原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。