Closed condorheroblog closed 1 month ago
Please let me explain the benefits of doing this.
For example, if I want to add a cache flag to the tab, I can directly call getCaches
through KeepAliveContext in this component.
Some closing operations of the tab can also be easily obtained through KeepAliveContext.
In this way, my tab component does not need to exchange data with the outside world, everything is done internally.
It is not necessary to reference https://github.com/irychen/super-admin. Keepalive will automatically manage cached React nodes, so the important thing is to manage the tab's data, which is independent of the Keepalive cached nodes. Even manually removing cached nodes is not necessary
If you believe it is meaningful for your project, you can commit a pull request (PR). There is a good opportunity to refactor the useImperativeHandle code implementation because it contains redundant code in relation to the props of CacheComponent.
If you don't have spare time, perhaps I will add this feature next month
The properties and methods on the
KeepAliveRef
method should also be available on theKeepAliveContext
.The reason for this is that sub components can flexibly read and control the behavior of KeepAlive through the KeepAliveContext.