Answer the question
In order to leave comments, you need to log in
How to add a react component to an existing site?
I have prepared a react component and want to use it on an existing site. I'm using an example from the react spec. When trying to connect the component in the console, an error occurs:
Uncaught SyntaxError: Cannot use import statement outside a module
Answer the question
In order to leave comments, you need to log in
here they say that import cannot be used like this: https://github.com/babel/babel-standalone/issues/71
you need to build the webpack bundle normally.
as an option, you can try changing babel settings so that it generates not a commonjs module (this is the default babel-standalone setting) but es-module, then there is a chance that type="module" will work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question