Should I reset store state on router navigations?

563 views Asked by At

TLDR: A lot of data, do you need to reset the data in the store on navigations, memorywise?

Say I have tons of tons of data, few hundreds of thousands of entries in the db, and the user in that session scrolled down my endless-scroll container so many times it fetched a lot of it, at least a thousand entities.

Then, he decided to navigate to another page displaying some other content, independent of the previous page data.

Should I clear the state slice of the previous page on navigation? so the app won't be getting high memory usage, etc..?

And If so, is there a built way to do that? the only way i found is dispatching a reset action to the store before each navigation, is there a cleaner way?

Note: The user would probably come back to the previous page while using the app at some time.

I've found this question kinda addressing the same thing but not memorywise, more of a cleaner flow of the app.

Any insights would be highly appreciated!

1

There are 1 answers

1
Jaroslaw K. On

If data is REALLY a lot, it would be unwise to saving them all, because of browser memory.

Optimalization your app will be due to many factors (average time of using app by user, frequently changing data, etc.). But if you already have implementation of infinity scroll, I guess that the best way will be saving first page (or the first few) results. User will get the impression of fast data loading, and inifinity scroll will still perform their function.