safak / next-blog

316 stars 318 forks source link

I don't know where the problem is, the local storage is not working and the screen is white ? #46

Open zakariyaehamdaoui opened 4 months ago

zakariyaehamdaoui commented 4 months ago

`at ThemeContextProvider (./src/context/Themecontext.jsx:20:78) digest: "987892600" 5 | const getFromLocalStorage = () => { 6 | if (typeof window !== undefined) {

7 | const value = localStorage.getItem("theme"); | ^ 8 | return value || "light"; 9 | } 10 | };`

ddddd

Bdisha123 commented 4 months ago

did you find the solution?

starlove54 commented 3 months ago

i think the way the code is written it tries to access local storage on server and since its a browser thing so it might give an error (even though use client is used) so i changed the logic a bit here and that removes error

Screenshot 2024-06-28 at 3 02 00 PM