Reputation: 5117
I am writing a react-redux application, that has some 4 routes. I am using react-router to navigate to different routes. My question here is, is it recommended to delete redux state on navigating to a different route?
Upvotes: 1
Views: 1912
Reputation: 3988
As other's here said, there is no reason to delete state from redux, even if you're not using it in the current route.
You said that you're loading your state on componentDidMount
. Do you want to reload server data every time a route is switched? Because if not, you can add a condition to your componentDidMount
to only re-load the data from the server if it hasn't been loaded yet.
Upvotes: 1
Reputation: 47279
In general I would not say it is needed to delete existing state when transitioning to another route in the app. If you come back to that part, you can display data faster. You might need to consider if there is a need to refresh that when you come back to it.
Upvotes: 1