Skip to content

Commit

Permalink
fix: lint issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
xobotyi committed Apr 6, 2021
1 parent 4e07c7e commit 5a5a575
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/useSetState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ const useSetState = <T extends object>(
initialState: T = {} as T
): [T, (patch: Partial<T> | ((prevState: T) => Partial<T>)) => void] => {
const [state, set] = useState<T>(initialState);
const setState = useCallback(
(patch) => {
set((prevState) =>
Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch)
);
},
[]
);
const setState = useCallback((patch) => {
set((prevState) =>
Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch)
);
}, []);

return [state, setState];
};
Expand Down

0 comments on commit 5a5a575

Please sign in to comment.