-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript Issue with React when instantiating new Shuffle #214
Comments
This seems like an issue with your build system. If you console log Shuffle, what is it? |
Thanks for the quick response! I placed the console statement here:
|
The issue is that you're importing the object here and trying to use that as the constructor. This is what you have now: { default: Shuffle } Can you remove the import Shuffle from 'shufflejs'; or maybe import { default as Shuffle } from 'shufflejs'; |
Hi, I don't think this ticket is resolved yet. // index.d.ts
// line 6, currently:
export = Shuffle;
// should be:
export default Shuffle; If this were a commonjs module, // es6 module
import Shuffle from 'shufflejs'
// commonjs module
import * as Shuffle from 'shufflejs' But this is an es6 module, so there is a 'default' member and the definition should reflect that. I hope that helps! No snark intended, just want to be thorough :) |
If you're using CommonJS, you will need to `import * as Shuffle from 'shufflejs'`. If you're using webpack and ts is configured to maintain `import`s, you can use it like `import Shuffle from 'shufflejs'`
Released in |
Shuffle version
5.1.1
Steps to reproduce
Here is my component code:
What is Expected?
An error is does not occur in the componentDidMount.
What is actually happening?
"TypeError: WEBPACK_IMPORTED_MODULE_2_shufflejs is not a constructor" occurs on the line where
this.shuffle = new Shuffle(this.element as Element, {...
in the componentDidMount.The text was updated successfully, but these errors were encountered: