score:38

Accepted answer

edit: oddly, after our comments above, i checked to see if it was indeed the babel core version, i am using this one in my fiddle:

https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js

the second i switch to your version above i get this:

uncaught typeerror: cannot read property 'keys' of undefined

use react.createclass not reactdom.createclass and wrap multiple lines of html in parenthesis like so:

working example: https://jsfiddle.net/69z2wepo/38998/

var hello = react.createclass({
  render: function() {
    return (     
       <div>
        <h1>hello world</h1>
        <p>this is some text</p>
       </div>
    )
  }
});

reactdom.render(
  <hello name="world" />,
  document.getelementbyid('container')
);

score:-3

i haven't worked with react before, but there are a few things that i see that may be causing your issues. first, react.createclass instead of reactdom.createclass. second, you need to wrap your html in parentheses:

var helloworld = react.createclass({
  render: function() {
    return (
      <div>
        <h1>hello world</h1>
        <p>this is some text></p>
      </div>
    );
  }
});

this should get it working

score:0

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.29/browser.js"></script>

this is the version of babel-core which isn't giving me the error as shown below:

if you want to use the latest version, you can use the latest standalone version. (as per 22-nov-2018)

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.24.0/babel.js"></script>

but this gives the following warning :

"you are using the in-browser babel transformer. be sure to precompile your scripts for production - https://babeljs.io/docs/setup/"

enter image description here

score:3

today is my first day with react, and i've faced this issue when i tried to use babel to transpile the jsx!

the issue is the version you are trying to use, please use this one instead:

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.25.0/babel.min.js"></script>

don't forget to write type="text/babel" in the <script> tag which you will write the jsx in to let babel transpile it for you, if you don't, you will find this error (as i have faced it too! :d):

uncaught syntaxerror: unexpected token <

score:10

just to be clear, as the other answers are a bit convoluted. the problem was using "babel-core" instead of "babel-standalone". just look up for a cdn for babel-standalone instead.

https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.js

Related Query

More Query from same tag