From 1a4affacef53f5121a47536728af1aa5ddbbf878 Mon Sep 17 00:00:00 2001 From: toniocodo Date: Thu, 25 Jul 2024 23:29:28 +0200 Subject: [PATCH] fix: slider switch width --- libs/shared/components/src/Switches/SliderSwitch.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/shared/components/src/Switches/SliderSwitch.tsx b/libs/shared/components/src/Switches/SliderSwitch.tsx index 8026293bb..e2c0422f4 100644 --- a/libs/shared/components/src/Switches/SliderSwitch.tsx +++ b/libs/shared/components/src/Switches/SliderSwitch.tsx @@ -1,4 +1,4 @@ -import { forwardRef, useLayoutEffect, useRef, useState } from 'react'; +import { forwardRef, useEffect, useRef, useState } from 'react'; import { Box, Button, emphasize, Stack, Typography } from '@mui/material'; import { isNilOrEmpty } from '@origin/shared/utils'; @@ -28,9 +28,9 @@ export const SliderSwitch = ({ const refs = useRef([]); const [itemsWidth, setItemsWidth] = useState([]); - useLayoutEffect(() => { + useEffect(() => { setItemsWidth(refs.current.map((o) => o.offsetWidth)); - }, []); + }, [options]); const idx = options.findIndex((o) => isNilOrEmpty(o.value) ? isNilOrEmpty(value) : o.value === value,