codeaashu / DevDisplay

DevDisplay is a global open source community platform that brings together all your tech needs in one place. 🌟 Join DevDisplay to Showcase your skills, connect globally, collaborate, build and promote.
https://www.devdisplay.org
MIT License
144 stars 283 forks source link

🛠️FIX : Uncaught Runtime Error Prevents Local Development #560

Open akash70629 opened 2 days ago

akash70629 commented 2 days ago

Description

After forking and cloning the repository, I encountered a major issue while setting up the local environment. Upon running npm install and npm start, I received an uncaught runtime error.

To resolve this, you can modify your code to handle the case where the stored theme is a simple string instead of a JSON string. Here's how you can do that:

Retrieving the theme: Instead of using JSON.parse, you directly retrieve the item from local storage. Checking for storedTheme: If storedTheme is not null (meaning there is a value stored), it will return that value directly, which should be either "dark" or "light". Fallback: If there’s no stored theme, it defaults to checking the document's class to determine the current theme. This approach avoids any JSON parsing issues and should fix the "Unexpected token 'd'" error.

I fixed that.

Related Issues

Fixes : #489

Changes Proposed

Changed some line of code on Sidebar.jsx

Checklist

Screenshots

Before

https://github.com/user-attachments/assets/76dc452d-09d0-4295-8cc0-a0735a92ce35

After

https://github.com/user-attachments/assets/87326385-d650-40af-86f1-1ea40e7a39dd

vercel[bot] commented 2 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
devdisplay ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2024 3:03pm
akash70629 commented 14 hours ago

@madhukalita please review and merge the PR .