Leocardoso94 / animated-number-react

Super easy way to animate numbers with React
MIT License
104 stars 13 forks source link

Infinite loop if value prop is set to 0 #22

Open noah79 opened 3 years ago

noah79 commented 3 years ago

Offending code:

  updateValue = (anima) => {
    this.props.update(anima)
    const {animatedValue} = this.target
    this.setState({animatedValue})
  }

Should be:

  updateValue = (anima) => {
    this.props.update(anima)
    const {animatedValue} = this.target
    if (animatedValue !== this.state.animatedValue) {
      this.setState({animatedValue})
    }
  }