react-spring icon indicating copy to clipboard operation
react-spring copied to clipboard

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

Open FireworksX opened this issue 2 years ago • 1 comments

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

FireworksX avatar Jun 24 '24 07:06 FireworksX

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

FireworksX avatar Jun 24 '24 16:06 FireworksX