ameyms / react-animated-number

React component for animating numbers
MIT License
168 stars 28 forks source link

Only works after state change? #10

Open screendriver opened 7 years ago

screendriver commented 7 years ago

For example I want to display an animated number with a static number:

<AnimatedNumber
  value={1234}
  duration={2500}
  stepPrecision={0}
  formatValue={(n: number) => n.toLocaleString()}
/>

This does not work (it does not animate). It only animates when I set an initial value of 0 and change this value afterwards with a state change.

Is this behaviour as expected?

adc-jasonc commented 7 years ago

I traced the code, I suspect there is somehow now a bug at https://github.com/ameyms/react-animated-number/blob/master/src/AnimatedNumber.jsx#L90 props.value is no longer the value when endTween() was called...

ImanMh commented 6 years ago

same issue here

sayedsaeedhosseini commented 6 years ago

1+