aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/forms/motion-toggle/motion-toggle.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-05 18:58:30 +0200
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:14:41 +0100
commitfb860884857da73ee5b5e897745301cdf1d770a2 (patch)
tree3aaf3c192b3375a7e1bf2dbf9daa866be357a2f5 /src/components/organisms/forms/motion-toggle/motion-toggle.tsx
parente97325a2c174a87c29593d1b42b9a1cc1eaf11af (diff)
refactor(components): make form components compliant with Eslint rules
Diffstat (limited to 'src/components/organisms/forms/motion-toggle/motion-toggle.tsx')
-rw-r--r--src/components/organisms/forms/motion-toggle/motion-toggle.tsx14
1 files changed, 9 insertions, 5 deletions
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