File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -85,14 +85,16 @@ const useConfetti = ({
8585 const ctxRef = useRef ( )
8686
8787 const onCanvasResize = useCallback ( ( ) => {
88- const canvas = canvasRef . current
89- const canvasBB = canvas . getBoundingClientRect ( )
90- const { width, height } = canvasBB
91- const scale = window . devicePixelRatio
92- canvasBBRef . current = canvasBB
93- canvas . scale = scale
94- canvas . width = Math . floor ( width * scale )
95- canvas . height = Math . floor ( height * scale )
88+ if ( canvasRef . current ) {
89+ const canvas = canvasRef . current
90+ const canvasBB = canvas . getBoundingClientRect ( )
91+ const { width, height } = canvasBB
92+ const scale = window . devicePixelRatio
93+ canvasBBRef . current = canvasBB
94+ canvas . scale = scale
95+ canvas . width = Math . floor ( width * scale )
96+ canvas . height = Math . floor ( height * scale )
97+ }
9698 } , [ ] )
9799
98100 // Observe for canvas size changes
You can’t perform that action at this time.
0 commit comments