update useLocalState to use initialValue directly as useState initialState
This commit is contained in:
parent
255769c3a9
commit
c57f93802b
|
@ -5,11 +5,13 @@ export function useLocalState<T>(
|
|||
key: LS_KEYS,
|
||||
initialValue?: T
|
||||
): [T, Dispatch<SetStateAction<T>>] {
|
||||
const [value, setValue] = useState<T>();
|
||||
const [value, setValue] = useState<T>(initialValue);
|
||||
|
||||
useEffect(() => {
|
||||
const { value } = getData(key) ?? {};
|
||||
setValue(value ?? initialValue);
|
||||
if (value) {
|
||||
setValue(value);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
Loading…
Reference in a new issue