How to unmount, unrender or remove a component, from itself in a React/Redux/Typescript notification message

后端 未结 5 661
臣服心动
臣服心动 2020-12-02 06:44

I know this question has been asked a couple of times already but most of the time, the solution is to handle this in the parent, as the flow of responsibility is only desce

5条回答
  •  Happy的楠姐
    2020-12-02 06:44

    I've been to this post about 10 times now and I just wanted to leave my two cents here. You can just unmount it conditionally.

    if (renderMyComponent) {
      
    }
    

    All you have to do is remove it from the DOM in order to unmount it.

    As long as renderMyComponent = true, the component will render. If you set renderMyComponent = false, it will unmount from the DOM.

提交回复
热议问题