-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ec issue #29 bug fix - Lists in the Nav Bar throw error when local storage is empty #60
Conversation
Visit the preview URL for this PR (updated for commit 31ee93d): https://tcl-66-smart-shopping-list--pr60-ec-issue-29-bug-fix-9cho9qzz.web.app (expires Thu, 11 Apr 2024 23:47:12 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 2dc16cb2a79cbd6723fdc511b73e0743df1d18d0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job Emilio. Everything seems to be working on my end!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does fix the issue of the page breaking when the user has never been on a list and they sign in for the first time but it loses the feature of the bullet point being blue for the list the current user is on.
You should be able to fix the one issue while keeping the blue bullet feature.
If you need a hint: Try console.logging localStorageListName
, and then look into optional chaining: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
Thanks, @jeremiahfallin. I fixed the issue using your optional chaining solution. I also fixed a related problem with a blue background not being applied to the nav bar list element that is being viewed on the list page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix, approved!
Description
The list elements in the Navigation Bar contained a const declaration that used the "getItem" method to obtain a value from local storage. When this method was run, an error would occur when local storage was empty or did not contain a value for the key, "tcl-shopping-list-path". Specifically, the application would throw an error and the home page would be blank after signing in to the app.
Updates
To resolve this bug that stemmed from the
NavigationBarSingleList
component, I changed the localStorageListName const declaration to an arrow function and added a try-catch statement.Before Bug Fix
Testing Steps / QA Criteria
Steps to reproduce the behavior: