Unmounting React.js node

前端 未结 6 508
北海茫月
北海茫月 2020-12-07 18:36

I\'m trying to unmount a React.js node with this._rootNodeID

 handleClick: function() {

        React.unmountComponentAtNode(this.         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 19:30

    Unmount components from the same DOM element that you mount them in. So if you did something like:

    ReactDOM.render(, document.getElementById('container'));
    

    Then you would unmount it with:

    ReactDOM.unmountComponentAtNode(document.getElementById('container'));
    

    Here is a simple JSFiddle where we mount the component and then unmount it after 3 seconds.

提交回复
热议问题