-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
useState is conditionally called which is against the rules of hooks: https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level
export const useLocalStorage = (key: string) => {
if (typeof window === 'undefined' || typeof key !== 'string' || !key) {
return [null, (_: string) => null];
}
const [value, setValue] = useState<string>(window.localStorage.getItem(key) || '');Metadata
Metadata
Assignees
Labels
No labels