繁体   English   中英

react-draggable 无法在未安装的组件上找到节点

[英]react-draggable Unable to find node on an unmounted component

每当我在插入 Draggable 组件后刷新页面时,我的页面就会停止渲染,并且 HTML 根元素不再有任何子元素。 我已经尝试将它放在主 App 组件中,但在控制台中仍然出现相同的错误。

import React from 'react'
import Draggable from 'react-draggable';
import './Styles.css';

function Card() {
  
  return (
    <Draggable>
      <div className='SCard'>
        <div>Text</div>
      </div>
    </Draggable>
  )
}

export default Card
react-dom.development.js:4303 Uncaught Error: Unable to find node on an unmounted component.
    at findCurrentFiberUsingSlowPath (react-dom.development.js:4303:1)
    at findCurrentHostFiber (react-dom.development.js:4465:1)
    at findHostInstanceWithWarning (react-dom.development.js:25389:1)
    at Object.findDOMNode (react-dom.development.js:26067:1)
    at DraggableCore.findDOMNode (DraggableCore.js:389:1)
    at DraggableCore.componentDidMount (DraggableCore.js:352:1)
    at commitLayoutEffectOnFiber (react-dom.development.js:23305:1)
    at commitLayoutMountEffects_complete (react-dom.development.js:24688:1)
    at commitLayoutEffects_begin (react-dom.development.js:24674:1)
    at commitLayoutEffects (react-dom.development.js:24612:1)
findCurrentFiberUsingSlowPath @ react-dom.development.js:4303
findCurrentHostFiber @ react-dom.development.js:4465
findHostInstanceWithWarning @ react-dom.development.js:25389
findDOMNode @ react-dom.development.js:26067
findDOMNode @ DraggableCore.js:389
componentDidMount @ DraggableCore.js:352
commitLayoutEffectOnFiber @ react-dom.development.js:23305
commitLayoutMountEffects_complete @ react-dom.development.js:24688
commitLayoutEffects_begin @ react-dom.development.js:24674
commitLayoutEffects @ react-dom.development.js:24612
commitRootImpl @ react-dom.development.js:26823
commitRoot @ react-dom.development.js:26682
finishConcurrentRender @ react-dom.development.js:25981
performConcurrentWorkOnRoot @ react-dom.development.js:25809
workLoop @ scheduler.development.js:266
flushWork @ scheduler.development.js:239
performWorkUntilDeadline @ scheduler.development.js:533
react-dom.development.js:18687 The above error occurred in the <DraggableCore> component:

    at DraggableCore (http://localhost:3000/static/js/bundle.js:72974:5)
    at Draggable (http://localhost:3000/static/js/bundle.js:72264:5)
    at StressCard
    at div
    at div
    at div
    at div
    at App

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.

令人惊讶的是,我没有发现其他人报告这个问题,因为它只是在实施时起作用。 任何帮助表示赞赏(请非常具体,因为我对 web 开发人员很陌生),谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM