# extendify/3.0.4/src/Launch/hooks/useConfetti.js

Extendify, version 3.0.4. 24 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.0.4/code/src/Launch/hooks/useConfetti.js
- Raw: https://pluginprobe.com/plugins/extendify/3.0.4/raw/src/Launch/hooks/useConfetti.js
- Modified: 2023-10-11T02:07:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.0.4/code/src/Launch/hooks/useConfetti.js#L10-L20`.

```javascript
import { useEffect } from '@wordpress/element';
import confetti from 'canvas-confetti';

export const useConfetti = (config = {}, time = 0, ready = false) => {
	useEffect(() => {
		if (!ready) return;
		const secondsFromNow = Date.now() + time;
		const frame = () => {
			confetti({
				...config,
				disableForReducedMotion: true,
				zIndex: 100000,
			});
			if (Date.now() < secondsFromNow) {
				// run every two frames
				requestAnimationFrame(() => {
					requestAnimationFrame(frame);
				});
			}
		};
		frame();
	}, [config, time, ready]);
};

```
