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
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.