Skip to content

React Refresh Does not work. #76

Closed Answered by Mhamad-Raad
gaurishhs asked this question in Q&A
Discussion options

You must be logged in to vote

I am not sure if I understood the question correctly, but if you mean that when you refresh the page (which means the page loads again from the server) it is normal behavior that the context starts being empty again, I would suggest you use local-storage or anything of that sort if you want the data to stay or have default values, use it with useEffect, like the followings:

useEffect(() => {
if (!logo) setLogo(CODOC_APP_CONTEXT.logo);
if (!title) setTitle(CODOC_APP_CONTEXT.title);
if (!navLinks) setNavLinks(CODOC_APP_CONTEXT.navLinks);
if (!sidebar) setSidebar(CODOC_APP_CONTEXT.sidebar);
if (!footer) setFooter(CODOC_APP_CONTEXT.footer);
}, [logo, title, navLinks, sidebar, footer]);

It's…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gaurishhs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants