react-range
react-range copied to clipboard
Injecting a new value to slider...
Hello, we have an application that reads all the light settings in our home, using DALI technology with RPi_HAT that can query each "ballast" that dims up/down from manual switches.
I've been trying to inject these light levels into my sliders, but can't find a way to do this once the slider has started.
Is there a simple way to inject a new value and have the slider move to that spot ?
Thank you !
UPDATE: This was by pure chance and experimenting...
export default function Slider(props) {
const [ballast, setBallast] = useGetAndSet(props.keys) // from: react-context-hook
const [values, setValues] = useState(props.values)
const setFinal = setBallast
useEffect(() => {
setValues(ballast)
})
As we're using "react-context-hook", I had to convert the Component into a Hook function...
The useEffect is inside the "slider.js", picking up any update that comes in through the "react-context-hook" (we're using socket.io and other means to update multiple sliders on same page).
I'm afraid I have not solved this on my own... useEffect alone does not allow me to set the slider value...