Import deleted files through ES6 import

I have an ES6 React application that has been compiled and added via a browser.

I have several import statements, for example:

import React from 'react/addons' 

I also need to use an external library that creates an HTML widget hosted on a CDN. I tried to include the file before or after the package source:

 <script src="//cdn.auth0.com/js/lock-7.9.min.js"></script> <script type="text/javascript" src="scripts/build.js"></script> 

When I try to reference the provided CDN object in the console, it works fine:

 Auth0Lock <-function Auth0Lock()... 

Linking to it in a React application causes a syntax error. I guess I need to import this ... but how?

+6
source share
1 answer

You can install auth0-lock via npm and use it as a local dependency

 npm install auth0-lock --save 

and then import it into your application like this

 import Auth0Lock from 'auth0-lock'; 
+4
source

All Articles