Design comparison
SolutionDesign
Solution retrospective
If someone knows how to save properly in local storage and keep the list updated on reload with my code as is, I would be very grateful!
Community feedback
- @wdbybPosted almost 2 years ago
Hello there! Here is my solution that I honestly pickep up on https://youtu.be/a_7Z7C_JCyo?t=16632 You're interesting in "Grocery-Bud Local Storage" part of video (if something goes wrong with the link)
const getLocaleStorage = () => { let todos = localStorage.getItem('todos'); if (todos) { return JSON.parse(todos); } return []; }; const App = () => { const [buttons, setButtons] = useState( getLocaleStorage() ); ... useEffect(() => { localStorage.setItem('todos', JSON.stringify(buttons)); }, [buttons]); };
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord