>
);
}
}
ReactDOM.render(
,
document.getElementById(´root´)
);
**[⬆ back to top](#table-of-contents)**
```
## Module component
```js
//App.js
import React, { Component } from 'react';
class App extends Component {
render() {
return (
My App
);
}
}
export default App
```
```js
//Index.js
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import App from './App.js';
class Index extends Component {
render() {
return (
);
}
}
ReactDOM.render (
,
document.getElementById('root')
);
```
**[⬆ back to top](#table-of-contents)**
---
## Hot Module Replacement
* Retain application state which is lost during a full reload.
* Save valuable development time by only updating what's changed.
* Tweak styling faster -- almost comparable to changing styles in the browser's debugger.
```js
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import MyComponent from './MyComponent';
ReactDOM.render( , document.getElementById('root') );
if (module.hot) {
module.hot.accept();
}
```
**[⬆ back to top](#table-of-contents)**
---
## Props
```js
import React, { Component } from 'react';
class App extends Component {
render() {
return (
My App {this.props.name}
);
}
}
class Index extends Component {
render() {
return (
);
}
}
export default Index;
```
**[⬆ back to top](#table-of-contents)**
---
## State
```js
import React, { Component } from 'react';
class App extends Component {
constructor(props) {
super(props);
this.state = {messages: 0};
}
render() {
return (
My messages: {this.state.messages}
);
}
}
export default App;
```
**[⬆ back to top](#table-of-contents)**
---
## Methods and Events
```js
import React, { Component } from 'react';
class App extends Component {
escreve() {
console.log("Eu te amo");
}
render() {
return (
);
}
}
export default App;
```
**[⬆ back to top](#table-of-contents)**
---
d
## Bindings
```js
import React, { Component } from 'react';
class MyComponent extends Component {
constructor () {
super();
this.state = { list: list };
this.doSomethingElse = this.doSomethingElse.bind(this);
};
doSomething = () => {
// do something
/* if don't have a parameter, you can use arrow function
and don't need to use bind */
}
doSomethingElse ( itemId ) {
// do something else
}
render() {
return (