如果 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)
有没有办法避免或解决这个错误?