MediumReact Utilities📖 Theory Question

Implement useLocalStorage hook

Full Answer

Key Insight: Always JSON.parse/stringify for localStorage — it only stores strings. Inject storage as a dependency for testability. In real hooks, trigger re-render by wrapping value in useState and calling setStoredValue.

Practice this in a timed sprint →

5 free questions, no signup required

⚡ Start Sprint