mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
parent
a247692fd6
commit
5f5376c64e
@ -1,7 +1,10 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { isClient } from './util';
|
||||
|
||||
const useLocalStorage = <T>(key: string, initialValue?: T, raw?: boolean): [T, (value: T) => void] => {
|
||||
type Dispatch<A> = (value: A) => void;
|
||||
type SetStateAction<S> = S | ((prevState: S) => S);
|
||||
|
||||
const useLocalStorage = <T>(key: string, initialValue?: T, raw?: boolean): [T, Dispatch<SetStateAction<T>>] => {
|
||||
if (!isClient) {
|
||||
return [initialValue as T, () => {}];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user