Open mjhamm75 opened 8 years ago
Can you elaborate on exactly what you're trying to do? :)
Hey, i had a similar question. I have something like:
import React from 'react';
const main = () => {
return eval(Babel.transform(code, { presets: ['es2015', 'react']}).code)
}
But encountered React is not defined
. Do you have any advice for it? Thanks!
But encountered React is not defined.
You need to load React. Easiest way is to load it from Facebook's CDN:
<script src="https://fb.me/react-15.1.0.min.js"></script>
<script src="https://fb.me/react-dom-15.1.0.min.js"></script>
Also note that you can't use import
statements with babel-standalone, as it does not provide any module system.
Ah okie, basically window.React
needs to be defined in my case
If I have a component <MyButton />
, is there a way to reference it?
@khankuan I also met the same scene, and I solved it in this way. I think it would not be the best way to mount all the objects on the window. Would you later find a better solution?
How do I create a
React
element from the string that is returned fromtransform
?