From fb860884857da73ee5b5e897745301cdf1d770a2 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Thu, 5 Oct 2023 18:58:30 +0200
Subject: refactor(components): make form components compliant with Eslint
 rules

---
 .../organisms/forms/motion-toggle/motion-toggle.tsx        | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

(limited to 'src/components/organisms/forms/motion-toggle/motion-toggle.tsx')

diff --git a/src/components/organisms/forms/motion-toggle/motion-toggle.tsx b/src/components/organisms/forms/motion-toggle/motion-toggle.tsx
index a8ca7ce..c141bf0 100644
--- a/src/components/organisms/forms/motion-toggle/motion-toggle.tsx
+++ b/src/components/organisms/forms/motion-toggle/motion-toggle.tsx
@@ -1,8 +1,12 @@
-import { ChangeEvent, FC } from 'react';
+import { useCallback, type FC } from 'react';
 import { useIntl } from 'react-intl';
 import { useAttributes, useLocalStorage } from '../../../../utils/hooks';
 import { Legend } from '../../../atoms';
-import { Switch, SwitchOption, SwitchProps } from '../../../molecules';
+import {
+  Switch,
+  type SwitchOption,
+  type SwitchProps,
+} from '../../../molecules';
 
 export type MotionToggleValue = 'on' | 'off';
 
@@ -37,7 +41,7 @@ export const MotionToggle: FC<MotionToggleProps> = ({
   );
   useAttributes({
     element:
-      typeof window !== 'undefined' ? document.documentElement : undefined,
+      typeof window === 'undefined' ? undefined : document.documentElement,
     attribute: 'reduced-motion',
     value: `${isReduced}`,
   });
@@ -71,9 +75,9 @@ export const MotionToggle: FC<MotionToggleProps> = ({
     },
   ];
 
-  const updateSetting = (e: ChangeEvent<HTMLInputElement>) => {
+  const updateSetting = useCallback(() => {
     setIsReduced((prev) => !prev);
-  };
+  }, [setIsReduced]);
 
   return (
     <Switch
-- 
cgit v1.2.3

