flipping
flipping copied to clipboard
"Uncaught TypeError: mitt is not a constructor"
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
I'm going to ditch mitt
and use a custom event emitter pattern.
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;
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
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';