diff --git a/README.md b/README.md index 7019a6a1ee..d161074d8b 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ - [`useGetSet`](./docs/useGetSet.md) — returns state getter `get()` instead of raw state. - [`useObservable`](./docs/useObservable.md) — tracks latest value of an `Observable`. - [`useSetState`](./docs/useSetState.md) — creates `setState` method which works like `this.setState`. [![][img-demo]](https://codesandbox.io/s/n75zqn1xp0) - - [`useToggle`](./docs/useToggle.md) — tracks state of a boolean. + - [`useToggle` and `useBoolean`](./docs/useToggle.md) — tracks state of a boolean. - [`useCounter`](./docs/useCounter.md) — tracks state of a number. - [`useList`](./docs/useList.md) — tracks state of an array. - [`useMap`](./docs/useMap.md) — tracks state of an object. diff --git a/docs/useToggle.md b/docs/useToggle.md index 3ad79ec821..93a4e4ec3b 100644 --- a/docs/useToggle.md +++ b/docs/useToggle.md @@ -2,11 +2,13 @@ React state hook that tracks value of a boolean. +`useBoolean` is an alias for `useToggle`. + ## Usage ```jsx -import {useToggle} from 'react-use'; +import {useToggle, useBoolean} from 'react-use'; const Demo = () => { const [on, toggle] = useToggle(true); diff --git a/src/__stories__/useBoolean.story.tsx b/src/__stories__/useBoolean.story.tsx new file mode 100644 index 0000000000..5d137a0633 --- /dev/null +++ b/src/__stories__/useBoolean.story.tsx @@ -0,0 +1,23 @@ +import * as React from 'react'; +import {storiesOf} from '@storybook/react'; +import {useBoolean} from '..'; +import ShowDocs from '../util/ShowDocs'; + +const Demo = () => { + const [on, toggle] = useBoolean(true); + + return ( +