|
1 |
| -import React, { Component, CanvasHTMLAttributes } from 'react' |
| 1 | +import React, { Component, CanvasHTMLAttributes, NamedExoticComponent } from 'react' |
2 | 2 | import Confetti, { IConfettiOptions, confettiDefaults } from './Confetti'
|
3 | 3 |
|
4 | 4 | export type Ref = HTMLCanvasElement
|
5 | 5 |
|
6 |
| -export type Props = Partial<IConfettiOptions> & CanvasHTMLAttributes<HTMLCanvasElement> & { |
7 |
| - canvasRef?: React.RefObject<HTMLCanvasElement> |
| 6 | +export type Props = Partial<IConfettiOptions> & NamedExoticComponent & CanvasHTMLAttributes<HTMLCanvasElement> & { |
| 7 | + canvasRef: React.RefObject<HTMLCanvasElement> |
8 | 8 | }
|
9 | 9 |
|
10 |
| -export class ReactConfetti extends Component<Props> { |
| 10 | +class ReactConfettiInternal extends Component<Props> { |
11 | 11 | static readonly defaultProps = {
|
12 | 12 | ...confettiDefaults,
|
13 | 13 | }
|
14 | 14 |
|
| 15 | + static readonly displayName = 'ReactConfetti' |
| 16 | + |
15 | 17 | constructor(props: Props, ...rest: any[]) {
|
16 | 18 | super(props, ...rest)
|
17 | 19 | this.canvas = props.canvasRef || React.createRef<HTMLCanvasElement>()
|
@@ -87,6 +89,8 @@ function extractCanvasProps(props: Partial<IConfettiOptions> | any): [Partial<IC
|
87 | 89 | return [confettiOptions, rest, refs]
|
88 | 90 | }
|
89 | 91 |
|
90 |
| -export default React.forwardRef<Ref, Props>((props, ref) => ( |
91 |
| - <ReactConfetti canvasRef={ref} {...props} /> |
| 92 | +export const ReactConfetti = React.forwardRef<Ref, Props>((props, ref) => ( |
| 93 | + <ReactConfettiInternal canvasRef={ref} {...props} /> |
92 | 94 | ))
|
| 95 | + |
| 96 | +export default ReactConfetti |
0 commit comments