platformer - v1.0.0
    Preparing search index...
    • React hook that synchronizes state with window.localStorage.

      Type Parameters

      • T

        Type of the stored value.

      Parameters

      • key: string

        The localStorage key.

      • initialValue: T

        Default value used if no value exists in storage or if parsing fails.

      Returns [T, (value: T | ((prev: T) => T)) => void]

      A tuple containing:

      • The current stored value.
      • A setter function that updates both state and localStorage.
      const [theme, setTheme] = useLocalStorage<'light' | 'dark'>('theme', 'light');