React component to draw confetti for your party.
npm install react-confetti


!npm type definitions
Based on a pen by @Gthibaud: https://codepen.io/Gthibaud/pen/ENzXbp
[![demogif][2]][1]
[1]: http://alampros.github.com/react-confetti
[2]: http://alampros.github.io/react-confetti/confetti-demo-anim.gif (demo gif)
``sh`
npm install react-confetti
width and height props are recommended. They will default to the initial window dimensions, but will not respond to resize events. It is recommended to provide the dimensions yourself. Here is an example using a hook:
`jsx
import React from 'react'
import { useWindowSize } from 'react-use'
import Confetti from 'react-confetti'
export default () => {
const { width, height } = useWindowSize()
return (
height={height}
/>
)
}
`
| Property | Type | Default | Description |
| ---------------- | --------------------- | --- | --- |
| width | Number | window.innerWidth \|\| 300 | Width of the
Draw a custom shape for a particle. If not provided, defaults to a random selection of a square, circle or strip confetto. The function is called with the canvas context as a parameter and the Particle as the this context.
For example, to draw all spirals:
`jsx``
ctx.beginPath()
for(let i = 0; i < 22; i++) {
const angle = 0.35 * i
const x = (0.2 + (1.5 angle)) Math.cos(angle)
const y = (0.2 + (1.5 angle)) Math.sin(angle)
ctx.lineTo(x, y)
}
ctx.stroke()
ctx.closePath()
}}
/>