They are shown when you run the tests. Until then they appear as a hidden requirement.
Create the useLocalStorage(key, initialValue) hook: it works like useState, but the value is saved in localStorage under key, so it survives a page reload, and it follows the changes that other tabs save. You practice custom hooks, effects with cleanup and JSON.
useLocalStorage and the export: the tests use the hook through a test component.localStorage lives in memory and starts empty every time the code reloads. In a real page it survives reloads.key (saved as JSON) or, if there is none, initialValue.[value, setValue]; setValue accepts a new value or a function of the previous one, like useState.key as JSON.storage event of window), the value updates.key, the hook returns what is stored under the new key (or initialValue), and what was stored under each key stays as it was.useLocalStorage("color", "green") with nothing stored → "green".setValue("blue") → it returns "blue", and localStorage.getItem("color") is "\"blue\""."blue" again.useState accepts a function that computes the initial value only once: read the storage there.
Save in an effect that depends on key and value.
Listen to storage in an effect, and remove the listener in its cleanup.
localStorage, JSON.stringify and JSON.parse.The console is empty
Run your code with Ctrl+S
This console starts empty every time the preview loads. The browser's DevTools console keeps the messages with Preserve log.