相关疑难解决方法(0)

React DOMException:无法在“节点”上执行“removeChild”:要删除的节点不是此节点的子节点

如果 state 是 true 播放 youtube 视频,并且它是 false 我想删除 youtube 播放。我的代码如下。

{this.state.isPreViewVideo && <PlayYouTube video_id="ScSn235gQx0" />}
Run Code Online (Sandbox Code Playgroud)

沙箱网址:

https://codesandbox.io/s/xryoz10k6o

繁殖方式:

如果输入表单中包含 4 位字符,则 setState 为“isPreViewVideo: true”,如果小于 false

当 state 为 true 时它工作正常,但是当 state 为 false 时,我会遇到以下错误。

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

Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Run Code Online (Sandbox Code Playgroud)

有没有办法避免或解决这个错误?

javascript reactjs

24
推荐指数
6
解决办法
3万
查看次数

标签 统计

javascript ×1

reactjs ×1