preact-router icon indicating copy to clipboard operation
preact-router copied to clipboard

Reuse the previous route instance

Open fantasia949 opened this issue 7 years ago • 1 comments

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?

fantasia949 avatar Oct 05 '17 17:10 fantasia949

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

developit avatar Nov 15 '17 03:11 developit