/** * Synchronizes state with sessionStorage, providing persistent storage for the current session. * Data persists only for the duration of the page session (until the tab is closed). * Automatically serializes/deserializes JSON values. * * @template T - The type of the stored value * @param key - The sessionStorage key * @param initialValue - The initial value if no stored value exists * @returns A tuple containing [storedValue, setValue, removeValue] * * @example * ```tsx * function WizardForm() { * const [formData, setFormData, clearFormData] = useSessionStorage('wizardForm', { * step: 1, * data: {} * }); * * const nextStep = () => { * setFormData(prev => ({ ...prev, step: prev.step + 1 })); * }; * * return ( *
Step {formData.step}
* * *