Skip to content

Conversation

alexieyizhe
Copy link
Contributor

While using react-confetti@3.1.2, it requires a canvasRef ref be passed in as a prop to the Confetti component. Looking at the constructor, if not provided, it will create and use a ref by default. It should be that the canvasRef prop is optional.

As a workaround, the canvasRef I passed to Confetti is just an arbitrary ref created with React.createRef, exactly the same as the one the component creates internally if props.canasRef is undefined.

@alexieyizhe
Copy link
Contributor Author

@alampros I'm also not seeing this canvasRef prop in the documentation README. Is that something I should update as well?

@alampros
Copy link
Owner

alampros commented Aug 6, 2019

The canvasRef prop is used internally for ref forwarding. It just occurred to me that the default export is different from the named class export and you might be getting the error because you are importing the member instead of the default.

Try using this:

import ReactConfetti from 'react-confetti'

instead of this:

import { ReactConfetti } from 'react-confetti'

I will put a fix version out that exports the same class as the default. Sorry about that!

@alampros alampros changed the title Make canvasRef prop optional Export same class member as default export Aug 6, 2019
BREAKING CHANGE: changes module exports
@alampros alampros merged commit df48e10 into alampros:develop Aug 6, 2019
@alampros
Copy link
Owner

alampros commented Aug 6, 2019

🎉 This PR is included in version 4.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@alexieyizhe
Copy link
Contributor Author

alexieyizhe commented Aug 15, 2019

@alampros I've been using the default export on v4.0.1, but it still requires the canvasRef prop for some reason. This is what I see in ReactConfetti.d.ts:

export declare const ReactConfetti: React.ForwardRefExoticComponent<Partial<IConfettiOptions> & React.CanvasHTMLAttributes<HTMLCanvasElement> & {
    canvasRef: React.RefObject<HTMLCanvasElement>;
} & React.RefAttributes<HTMLCanvasElement>>;

@HPieters
Copy link

I am getting the same typing issue as @alexieyizhe when using v4.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants