Skip to content

Commit

Permalink
fix: slider switch width
Browse files Browse the repository at this point in the history
  • Loading branch information
toniocodo committed Jul 25, 2024
1 parent 059fee6 commit 1a4affa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libs/shared/components/src/Switches/SliderSwitch.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -28,9 +28,9 @@ export const SliderSwitch = ({
const refs = useRef<HTMLButtonElement[]>([]);
const [itemsWidth, setItemsWidth] = useState<number[]>([]);

useLayoutEffect(() => {
useEffect(() => {
setItemsWidth(refs.current.map((o) => o.offsetWidth));
}, []);
}, [options]);

const idx = options.findIndex((o) =>
isNilOrEmpty(o.value) ? isNilOrEmpty(value) : o.value === value,
Expand Down

0 comments on commit 1a4affa

Please sign in to comment.