From 84a679b0e48ed76eee2fa44d3caac83591aa3c8c Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Mon, 30 Oct 2023 11:18:11 +0100
Subject: feat(hooks): add useBoolean and useToggle hooks

---
 src/components/organisms/toolbar/main-nav.stories.tsx | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

(limited to 'src/components/organisms/toolbar/main-nav.stories.tsx')

diff --git a/src/components/organisms/toolbar/main-nav.stories.tsx b/src/components/organisms/toolbar/main-nav.stories.tsx
index d79addf..31e2b65 100644
--- a/src/components/organisms/toolbar/main-nav.stories.tsx
+++ b/src/components/organisms/toolbar/main-nav.stories.tsx
@@ -1,5 +1,5 @@
 import type { ComponentMeta, ComponentStory } from '@storybook/react';
-import { useCallback, useState } from 'react';
+import { useToggle } from '../../../utils/hooks';
 import { MainNavItem } from './main-nav';
 
 /**
@@ -61,11 +61,7 @@ const Template: ComponentStory<typeof MainNavItem> = ({
   setIsActive: _setIsActive,
   ...args
 }) => {
-  const [isOpen, setIsOpen] = useState<boolean>(isActive);
-
-  const toggle = useCallback(() => {
-    setIsOpen((prevState) => !prevState);
-  }, []);
+  const [isOpen, toggle] = useToggle(isActive);
 
   return <MainNavItem isActive={isOpen} setIsActive={toggle} {...args} />;
 };
-- 
cgit v1.2.3

