Suppose I have two routes /dashboard and /profile. Now I first visit /dashboard , data is fetched and shown on the page . Then I goto /profile page again data is fetched and displayed . Now when i go back to /dashboard page I dont want to fetch data again. How can I implement this in react? Any help will be great .
CodePudding user response:
- You can create your own cache mechanism using redux or context api,
- you can use react-query, it has inbuilt advanced caching option to fetch data
