Skip to content
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

"Uncaught TypeError: mitt is not a constructor" #9

Open
aholachek opened this issue May 31, 2018 · 4 comments
Open

"Uncaught TypeError: mitt is not a constructor" #9

aholachek opened this issue May 31, 2018 · 4 comments

Comments

@aholachek
Copy link

Hi, I recently tried to use Flipping in a project scaffolded with create-react-app but could not import Flipping due to the following error:

TypeError: mitt is not a constructor on line 74 of Flipping.js

Any advice? It seems like others have encountered this issue with mitt

@davidkpiano
Copy link
Owner

I'm going to ditch mitt and use a custom event emitter pattern.

@DavidHooper
Copy link

Here is how you can work around the issue for now without messing with Webpack (works with create-react-app).

import * as Mitt from 'mitt/dist/mitt.umd';
import { Emitter } from 'mitt';

const emitter = new Mitt() as Emitter;

@aholachek
Copy link
Author

I was able to get things to work with the current set up by doing
import Flipping from "flipping/dist/flipping",
I don't know if there's a better way

@luckydonald
Copy link

luckydonald commented Jun 30, 2018

For webpack also this config works:

{
//...
resolve: {
    extensions: ['.js'],
    //modules: [path.resolve(__dirname, 'src'), 'node_modules'],
    alias: {
        'mitt': 'mitt/dist/mitt.umd.js',
    },
  },
//...
}

Note: I'm just using the .js file with

import Flipping from 'flipping/lib/adapters/web';

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

No branches or pull requests

4 participants