Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding infinite React -count up component in Home.js #18

Open
Sattwikmaiti opened this issue Mar 21, 2023 · 3 comments
Open

Adding infinite React -count up component in Home.js #18

Sattwikmaiti opened this issue Mar 21, 2023 · 3 comments

Comments

@Sattwikmaiti
Copy link

Sattwikmaiti commented Mar 21, 2023

Trying to give an infinite count up effect to numerical values

// Events will show auto increamenting effect

@Sattwikmaiti
Copy link
Author

Sattwikmaiti commented Mar 21, 2023

 const [count, setCount] = useState(0);
 const [start, setStart] = useState(0);
const  [end, setEnd] = useState(67);
const [duration, setDuration] = useState(2);

 useEffect(() => {
const intervalId = setInterval(() => {
  setCount(end);
  setStart(end);
  setEnd(start);
}, duration * 1000 + 100); // add 100ms delay to prevent flicker

return () => {
  clearInterval(intervalId);
};
}, [start, end, duration]);

@Sattwikmaiti
Copy link
Author

Sattwikmaiti commented Mar 21, 2023

<CountUp start={start} end={end} duration={duration} useEasing={true} /> using like this

@moinak878
Copy link
Member

@Sattwikmaiti Thanks for the suggestion, feel free to create your feature branch in this repo and do send a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants