🛠️FIX : Uncaught Runtime Error Prevents Local Development #560
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
record_000002.mp4
After
record_000003.mp4