Skip to content

Commit

Permalink
add try catch to localStorageListName in NavigationBarSingleList comp…
Browse files Browse the repository at this point in the history
…onent
  • Loading branch information
3campos committed Apr 3, 2024
1 parent 97c6f74 commit 8a15c14
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/components/NavigationBarSingleList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ export function NavigationBarSingleList({
window.location.pathname.substring(
window.location.pathname.lastIndexOf('/') + 1,
) === 'list';
const localStorageListName = localStorage
.getItem('tcl-shopping-list-path')
.substring(
localStorage.getItem('tcl-shopping-list-path').lastIndexOf('/') + 1,
);

const localStorageListName = () => {
try {
localStorage
.getItem('tcl-shopping-list-path')
.substring(
localStorage.getItem('tcl-shopping-list-path').lastIndexOf('/') + 1,
);
} catch (e) {
console.error('error', e);
}
};

return (
<li
Expand Down

0 comments on commit 8a15c14

Please sign in to comment.