react-spring
react-spring copied to clipboard
[bug]: animated.input value don't update
Which react-spring target are you using?
- [X]
@react-spring/web - [ ]
@react-spring/three - [ ]
@react-spring/native - [ ]
@react-spring/konva - [ ]
@react-spring/zdog
What version of react-spring are you using?
9.7.3
What's Wrong?
When try to use animated.input with useSpring or new SpringValue input don't react on update.
To Reproduce
- Add spring
const [custom, customApi] = useSpring(() => ({ value: 1 })) - Add animated.input with value
<animated.input value={custom.value} /> - Update spring
customApi.start({ value: 5 })
Expected Behaviour
Input should react on spring
Link to repo
https://codesandbox.io/p/sandbox/romantic-jepsen-6cnjc7
Resolve as
const Input = animated(({ value, onChange }) => {
return <input type="number" value={value} onChange={e => onChange(+e.target.value)} />
})
<Input value={custom.value} onChange={v => customApi.start({ value: v })} />