diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-10-30 11:18:11 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:15:27 +0100 |
| commit | 84a679b0e48ed76eee2fa44d3caac83591aa3c8c (patch) | |
| tree | 1d418a6c514ff8a04b84ba35c98736e8450f968c /src/components/molecules | |
| parent | 60c49f18389ff625177a57277ef8f292a31097bf (diff) | |
feat(hooks): add useBoolean and useToggle hooks
Diffstat (limited to 'src/components/molecules')
| -rw-r--r-- | src/components/molecules/forms/flipping-label/flipping-label.stories.tsx | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/components/molecules/forms/flipping-label/flipping-label.stories.tsx b/src/components/molecules/forms/flipping-label/flipping-label.stories.tsx index c3c4f9a..906a488 100644 --- a/src/components/molecules/forms/flipping-label/flipping-label.stories.tsx +++ b/src/components/molecules/forms/flipping-label/flipping-label.stories.tsx @@ -1,5 +1,5 @@ import type { ComponentMeta, ComponentStory } from '@storybook/react'; -import { useCallback, useState } from 'react'; +import { useToggle } from '../../../../utils/hooks'; import { Button, Icon } from '../../../atoms'; import { FlippingLabel } from './flipping-label'; @@ -74,11 +74,10 @@ const Template: ComponentStory<typeof FlippingLabel> = ({ isActive, ...args }) => { - const [active, setActive] = useState<boolean>(isActive); - const updateState = useCallback(() => setActive((prev) => !prev), []); + const [active, toggle] = useToggle(isActive); return ( - <Button kind="neutral" onClick={updateState} shape="initial" type="button"> + <Button kind="neutral" onClick={toggle} shape="initial" type="button"> <FlippingLabel {...args} isActive={active} /> </Button> ); |
