-
Notifications
You must be signed in to change notification settings - Fork 0
/
react.js
40 lines (30 loc) · 1.28 KB
/
react.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React from 'react';
import ReactDOM from 'react-dom';
const people = ['Rowe', 'Prevost', 'Gare'];
const peopleLis = people.map(person =>
// expression goes here:
<li>{person}</li>
);
// ReactDOM.render goes here:
ReactDOM.render(<ul>{peopleLis}</ul>, document.getElementById('app'));
//-----------------------------------------------------------------------------------------------------
import React from 'react';
//creates a JavaScript object. This object contains properties that are needed to make React work,
//such as React.createElement() and React.Component.
import ReactDOM from 'react-dom';
//creates another JavaScript object. This object contains methods that help React interact with the DOM,
//such as ReactDOM.render().
class MyComponentClass extends React.Component {
//subclassing React.Component, you create a new component class. This is not a component!
//A component class is more like a factory that produces components. When you start making components,
//each one will come from a component class.
//Whenever you create a component class, you need to give that component class a name.
//That name should be written in UpperCamelCase.
render() {
return <h1>Hello world</h1>;
}
}
ReactDOM.render(
<MyComponentClass />,
document.getElementById('app')
);