Browse Source

Update react-without-jsx.md

Facebook codestyle
main
Christopher Chedeau 8 years ago
committed by GitHub
parent
commit
3071ad08f5
  1. 12
      docs/react-without-jsx.md

12
docs/react-without-jsx.md

@ -32,8 +32,10 @@ class Hello extends React.Component {
}
}
ReactDOM.render(React.createElement(Hello, {toWhat: 'World'}, null),
document.getElementById('root'));
ReactDOM.render(
React.createElement(Hello, {toWhat: 'World'}, null),
document.getElementById('root')
);
```
If you're curious to see more examples of how JSX is converted to JavaScript, you can try out [the online Babel compiler](https://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-0&code=function%20hello()%20%7B%0A%20%20return%20%3Cdiv%3EHello%20world!%3C%2Fdiv%3E%3B%0A%7D).
@ -45,8 +47,10 @@ If you get tired of typing `React.createElement` so much, one common pattern is
```js
var e = React.createElement;
ReactDOM.render(e('div', null, 'Hello World'),
document.getElementById('root'));
ReactDOM.render(
e('div', null, 'Hello World'),
document.getElementById('root')
);
```
If you use this shorthand form for `React.createElement`, it can be almost as convenient to use React without JSX.

Loading…
Cancel
Save