preact-router
preact-router copied to clipboard
Reuse the previous route instance
In my scenario, I have an index route that displays item list, and a detail route to show detail info for each item. The content of the index route is rarely changed, but I have to pay a cost (~100ms) to make it visible. Each time I view the content of the detail route, then navigate back to the index route, the transition is not quite smooth. Looking at the performance timeline, I notice the index route instance is destroyed and reconstructed again for each roundtrip, so it's not effective, especially when that route contains a bunch of child components. Is there any possible way to make the router be able to cache the prev route instance, and then reuse it again when user navigates back?
This is how preact worked in previous versions, but there are too many issues arising from caching DOM - most importantly, it's quite bad for memory management (images & videos never getting GC'd, etc).