heyman333 / react-animated-numbers

👾 Library showing animation of number changes in react.js
MIT License
246 stars 30 forks source link

Multiple instances of AnimatedNumber on one pages causes weird issues #56

Closed philmetzger closed 10 months ago

philmetzger commented 10 months ago

I have multiple instances of the counter in one component.

e.g.

  const [counterValue, setCounterValue] = useState(counter.count);

  const handleCount = async (increment: boolean) => {
    const newCount = increment ? counterValue + 1 : counterValue - 1;
    if (newCount >= 0) {
      setCounterValue(newCount);
    }
  };
<AnimatedNumber
        className='text-dark dark:text-paperdark flex items-center justify-center'
        fontStyle={{ fontSize: 60 }}
        animateToNumber={counterValue}
        includeComma={true}
      />
      <AnimatedNumber
        className='text-dark dark:text-paperdark flex items-center justify-center'
        fontStyle={{ fontSize: 60 }}
        animateToNumber={22}
        includeComma={true}
      />

However when I click on a button to increment the count, then all counts of other counters go to 0 Any ideas?

brennerm commented 9 months ago

Hey @philmetzger , I'm having the same issue. Would be glad to hear what the solution was.