Reputation: 450
I am using Skylink for video calling and I want to use in a react project. I know how to use it with Vanilla JavaScript as their demo project is at codepen But when I try to use it with react I am getting some errors. Here is how I tried:
import SkyLink from 'skylinkjs'
const skylink = new SkyLink();
But I get the following error:Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_3_skylinkjs___default.a is not a constructor
If I try to import like this:
import {SkyLink} from 'skylinkjs';
const skylink = new SkyLink();
then the error is
Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_3_skylinkjs__.SkyLink is not a constructor
and If I try to import all from the module and then call the function costructor:
import * as SkyLink from 'skylinkjs';
const skylink = new SkyLink();
the error will be this Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_3_skylinkjs__ is not a constructor
Can you please tell me what am I doing wrong?
Upvotes: 0
Views: 134
Reputation: 6133
You have a typo. Either of the following would work.
import { Skylink } from 'skylinkjs';
const skylink = new Skylink();
or
import skylinkjs from 'skylinkjs';
const skylink = new skylinkjs.Skylink();
Upvotes: 1