Skip to content

Commit

Permalink
fix: use function to correctly update state in useToggle
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich authored Jan 4, 2019
1 parent dd81ba5 commit d854d27
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/useToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const useToggle: UseToggle = state => {
return;
}

setValue(!value)
setValue(value => !value)
};

return [value, toggle];
Expand Down

0 comments on commit d854d27

Please sign in to comment.