heyman333 / react-animated-numbers

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

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

Closed philmetzger closed 8 months ago

philmetzger commented 8 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 7 months ago

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