Skip to content

Commit 54039d1

Browse files
committed
Refactor Range component to optimize offset value update
1 parent 15d9c2f commit 54039d1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/components/Range.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ export default function Range({ value, setValue, Left, Right, accent = Colors.ac
1818
const scale = useSharedValue(1)
1919

2020
useEffect(() => {
21-
offset.value = withTiming(containerWidth * value)
22-
// offset.value = containerWidth * value
21+
// offset.value = withTiming(containerWidth * value)
22+
offset.value = containerWidth * value
2323
// eslint-disable-next-line react-hooks/exhaustive-deps
2424
}, [containerWidth])
2525

2626
useEffect(() => {
27-
const timer = setTimeout(() => {
28-
offset.value = containerWidth * value
29-
}, 100)
27+
const timer = setTimeout(() => (offset.value = containerWidth * value), 100)
3028
return () => clearTimeout(timer)
3129
// eslint-disable-next-line react-hooks/exhaustive-deps
3230
}, [value])

0 commit comments

Comments
 (0)