const LOCAL_STORAGE_KEY = "task-list" function TodoList() { const [todoList, setTodoList] = useState(() => { return JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY)) || [] }); useEffect(() => { localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(todoList)); }, [todoList]); ...
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter