mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-25 13:13:08 +00:00
Update react-without-jsx.md
Facebook codestyle
This commit is contained in:
committed by
GitHub
parent
842d44dfa5
commit
3071ad08f5
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user