diff --git a/app/components/SliderInput.tsx b/app/components/SliderInput.tsx index 0426fe9..aff9780 100644 --- a/app/components/SliderInput.tsx +++ b/app/components/SliderInput.tsx @@ -1,6 +1,6 @@ import Slider from '@react-native-community/slider' import { Style } from 'constants/Global' -import { useState } from 'react' +import { useEffect, useState } from 'react' import { View, Text, StyleSheet, TextInput } from 'react-native' type SliderInputProps = { @@ -31,6 +31,11 @@ const SliderInput: React.FC = ({ }) => { const [textValue, setTextValue] = useState(value.toString()) + // This effect ensures that if `value` updates from the parent, this text is properly updated + useEffect(() => { + if (parseFloat(textValue) !== value) setTextValue(value.toString()) + }, [value]) + const handleSliderChange = (v: number) => { if (!isNaN(clamp(v, min, max, precision))) onValueChange(v) setTextValue(v.toString())