Skip to content

Commit

Permalink
fix(useStateWithHistory): support callback style setState
Browse files Browse the repository at this point in the history
Make `useStateWithHistory` support the callback style set state, e.g. `setState(current => current + 1)`.
  • Loading branch information
QingqiShi authored Dec 6, 2020
1 parent 11d4711 commit fca687d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/useStateWithHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function useStateWithHistory<S, I extends S>(
const setState = useCallback(
(newState: ResolvableHookState<S>): void => {
innerSetState((currentState) => {
newState = resolveHookState(newState);
newState = resolveHookState(newState, currentState);

// is state has changed
if (newState !== currentState) {
Expand Down

0 comments on commit fca687d

Please sign in to comment.