Skip to content

Commit

Permalink
fix: useLocalStorage types for functional updates
Browse files Browse the repository at this point in the history
Fix useLocalStorage types for functional updates
  • Loading branch information
wardoost authored Jul 10, 2019
2 parents 4730da6 + 5f5376c commit e2b8278
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/useLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -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, () => {}];
}
Expand Down

0 comments on commit e2b8278

Please sign in to comment.