Skip to content

Commit

Permalink
feat: 🎸 accept any value type in useToggle and cast it to bool
Browse files Browse the repository at this point in the history
BREAKING CHANGE: now useToggle and useBoolean accept any value type and cast it to
boolean.
  • Loading branch information
streamich committed Oct 29, 2018
1 parent 8a9d05e commit 869f767
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/useToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const useToggle: UseToggle = state => {
const [value, setValue] = useState<boolean>(state);

const toggle = (nextValue?: boolean) => {
if (typeof nextValue === 'boolean') {
setValue(nextValue);
if (typeof nextValue !== 'undefined') {
setValue(!!nextValue);
return;
}

Expand Down

0 comments on commit 869f767

Please sign in to comment.