Home > OS >  React fetch data every time page reloads
React fetch data every time page reloads

Time:11-16

I am making a react SPA application, atm I'm using fetch every time page loads, I would like to know if it's better to store such data(for example: user data) in Local Storage and if yes, what if some data in the backend DB changes?

Sorry if there are similar questions, I just couldn't find them, Thanks

CodePudding user response:

Store user data after fetching from server in local storage is good solution that I have used before.

Use React-Query

For update user data after that updated in DB I recommend using a swr approach packages like react-query which sync your local data with server immediately.

  • Related