Difficulty: 6/10custom hook, localStorage API, state syncjavascriptCopyScenario Questions0-2 years experience1Imagine you need a simple form that remembers the user's name between page reloads. How would you use a useLocalStorage hook to achieve that?2If you call your hook with a key that doesn't exist yet in localStorage, what value should it return and why?2-5 years experience1You're adding a dark‑mode toggle that should persist across sessions. Walk me through how you'd integrate a useLocalStorage hook, and what you would do if the stored value becomes corrupted JSON.Follow-up QuestionsHow would you handle a situation where localStorage is disabled or throws?What would you change to keep multiple tabs in sync when the value changes?Can you discuss the trade‑offs of storing large objects versus primitives?Suggest Improvement