Skip to content
Discussion options

You must be logged in to vote

Ok, I solved the problem. The issue was not with ThemeProvider; rather, it was with me wanting to pull a user's previous theme selection from localStorage. I thought I had solved that adding the typeof window !== 'undefined' && window.localStorage code, but what I did not realize was that the code, as I had written it, was returning a null value for the stored theme on the initial rendering of the site after it was built.

The added code on line 12 of the following screenshot fixed the problem (disregard the change inside the useEffect hook, that is irrelevant and a relic of me fiddling around). Sharing in case anybody else is dealing with the same issue and comes across this post.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bueide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #29574 on February 19, 2021 08:39.