pmndrs / react-spring

✌️ A spring physics based React animation library
http://www.react-spring.dev/
MIT License
27.73k stars 1.18k forks source link

[bug]: animated.input value don't update #2296

Closed FireworksX closed 1 week ago

FireworksX commented 1 week ago

Which react-spring target are you using?

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

Expected Behaviour

Input should react on spring

Link to repo

https://codesandbox.io/p/sandbox/romantic-jepsen-6cnjc7

FireworksX commented 1 week ago

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 })} />