Skip to content

Commit

Permalink
fix: Export the same class as the default export
Browse files Browse the repository at this point in the history
BREAKING CHANGE: changes module exports
  • Loading branch information
Aaron Lampros committed Aug 6, 2019
1 parent e38e080 commit 385f981
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/ReactConfetti.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React, { Component, CanvasHTMLAttributes } from 'react'
import React, { Component, CanvasHTMLAttributes, NamedExoticComponent } from 'react'
import Confetti, { IConfettiOptions, confettiDefaults } from './Confetti'

export type Ref = HTMLCanvasElement

export type Props = Partial<IConfettiOptions> & CanvasHTMLAttributes<HTMLCanvasElement> & {
canvasRef?: React.RefObject<HTMLCanvasElement>
export type Props = Partial<IConfettiOptions> & NamedExoticComponent & CanvasHTMLAttributes<HTMLCanvasElement> & {
canvasRef: React.RefObject<HTMLCanvasElement>
}

export class ReactConfetti extends Component<Props> {
class ReactConfettiInternal extends Component<Props> {
static readonly defaultProps = {
...confettiDefaults,
}

static readonly displayName = 'ReactConfetti'

constructor(props: Props, ...rest: any[]) {
super(props, ...rest)
this.canvas = props.canvasRef || React.createRef<HTMLCanvasElement>()
Expand Down Expand Up @@ -87,6 +89,8 @@ function extractCanvasProps(props: Partial<IConfettiOptions> | any): [Partial<IC
return [confettiOptions, rest, refs]
}

export default React.forwardRef<Ref, Props>((props, ref) => (
<ReactConfetti canvasRef={ref} {...props} />
export const ReactConfetti = React.forwardRef<Ref, Props>((props, ref) => (
<ReactConfettiInternal canvasRef={ref} {...props} />
))

export default ReactConfetti

0 comments on commit 385f981

Please sign in to comment.