-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-components.html
53 lines (42 loc) · 1.31 KB
/
03-components.html
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
41
42
43
44
45
46
47
48
49
50
51
52
53
<div id="root"></div>
<script src="http://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script src="http://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/[email protected]/babel.min.js"></script>
<script type="text/babel">
const rootElement = document.getElementById('root')
// 1.
// const domElement = (
// <div className="container">
// <div>Hello World</div>
// <div>Goodbye World</div>
// </div>
// )
const Message = (props) => <div>{props.msg}</div>
// 2.
// const domElement = (
// <div className="container">
// {message({ msg: 'Hello World' })}
// {message({ msg: 'Goodbye World' })}
// </div>
// )
// 3.
// const domElement = (
// <div className="container">
// {React.createElement(message, {msg: 'Hello World'})}
// {React.createElement(message, {msg: 'Goodbye World'})}
// </div>
// )
// const domElement = (
// <div className="container">
// <message msg="Hello World"/> (Doesn't work as small html tags denote the predefined one. So, we need to make use of the capitalised tags)
// </div>
// )
const domElement = (
<div className="container">
<Message msg="Hello World"/>
<Message msg="Goodbye World"/>
</div>
)
console.log(domElement)
ReactDOM.render(domElement, rootElement)
</script>