Uday Hiwarale
1 min readMar 4, 2019

--

Simone Bernasconi Yes, there are a couple of ways. First, you need to understand that when you change a route, that component unmounts first and new component specified by the new route mounts. Since the older component unmounted, any data in the state is lost. Since, we want to preserve the data, that data needs to be preserved somewhere where it doesn’t get lost when the route changes.

So if we have a parent component that never unmounts, it would be good if we can store the data there when child component performs some actions. Once child component remounts, it will receive it back as a prop. This is advisable in small applications. You can make use of context api for this.

But in case of a larger data-intensive application where we have multiple routes and larger data set, we need to use Redux or similar data store. But once you reload the application, Redux data store is lost. You need to use backend data storage in such cases or browser-based client-side data storage like IndexedDB.

--

--

No responses yet