flipping icon indicating copy to clipboard operation
flipping copied to clipboard

"Uncaught TypeError: mitt is not a constructor"

Open aholachek opened this issue 6 years ago • 4 comments

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

aholachek avatar May 31 '18 19:05 aholachek

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

davidkpiano avatar May 31 '18 20:05 davidkpiano

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;

DavidHooper avatar Jun 19 '18 07:06 DavidHooper

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

aholachek avatar Jun 19 '18 11:06 aholachek

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';

luckydonald avatar Jun 30 '18 17:06 luckydonald