How to create confetti in React JS

How to create confetti in React JS

ยท

1 min read

In this article, I will show you the easy and simple way to create confetti in React.

First, install the following dependency:

npm i canvas-confetti

After installing the above package, import it into your React application:

import confetti from 'canvas-confetti';

To create confetti using the package, create the following function:

const handleConfetti = () => {
    confetti();
 };

Now create a button with the onClick event:

<button onClick={handleConfetti}>Show Confetti</button>

This will create amazing and satisfying confetti ๐ŸŽ‰.

Check out the live version:


Thanks for reading

Follow me on Twitter

Thanks for reading!

ย