https://github.com/phalbert/pure-react
Explore react like the guy who first imported the script into index.html
https://github.com/phalbert/pure-react
pure react
Last synced: about 1 year ago
JSON representation
Explore react like the guy who first imported the script into index.html
- Host: GitHub
- URL: https://github.com/phalbert/pure-react
- Owner: phalbert
- Created: 2019-11-13T14:10:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-30T10:36:00.000Z (almost 2 years ago)
- Last Synced: 2025-01-23T07:29:45.017Z (about 1 year ago)
- Topics: pure, react
- Language: HTML
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pure-react
Explore react like the guy who first imported the script into index.html
## React Without JSX
JSX is not a requirement for using React. Using React without JSX is especially convenient when you don’t want to set up compilation in your build environment.
Each JSX element is just syntactic sugar for calling React.createElement(component, props, ...children). So, anything you can do with JSX can also be done with just plain JavaScript.
For example, this code written with JSX:
```javascript
class Hello extends React.Component {
render() {
return
Hello {this.props.toWhat};
}
}
ReactDOM.render(
,
document.getElementById('root')
);
```
can be compiled to this code that does not use JSX:
```javascript
class Hello extends React.Component {
render() {
return React.createElement('div', null, `Hello ${this.props.toWhat}`);
}
}
ReactDOM.render(
React.createElement(Hello, {toWhat: 'World'}, null),
document.getElementById('root')
);
```