I tried it but there was several errors with the latest versions of React.
At the end, I achieved basically the same result using https://github.com/httptoolkit/react-reverse-portal and building some component around it.
Basically I just created a Provider that store a list of mounted components (the core function is):
and then I invoke this function in the KeepAlive component using the useEffect.
Since this implementation uses react-reverse-portal I can use the standard useEffect hooks my component and all looks like super.
What do you think to consider to rewrite react-keep-alive with this suggestion so to be more compatible with latest version of React and then remove all the event communication inside of it?
I tried it but there was several errors with the latest versions of React. At the end, I achieved basically the same result using https://github.com/httptoolkit/react-reverse-portal and building some component around it.
Basically I just created a Provider that store a list of mounted components (the core function is):
and the render is like
and then I invoke this function in the KeepAlive component using the useEffect.
Since this implementation uses react-reverse-portal I can use the standard useEffect hooks my component and all looks like super.
What do you think to consider to rewrite react-keep-alive with this suggestion so to be more compatible with latest version of React and then remove all the event communication inside of it?