-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-intro-react.html
50 lines (36 loc) · 1.44 KB
/
02-intro-react.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="root" style="border: 1px solid red"></div>
<script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
'' <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>
<script>
const root = document.getElementById('root')
// props = atributos de um elemento HTML
// Em react, são representadas por meio de um objeto
let props = {
style: {border: '2px solid blue', backgroundColor: "aliceblue"},
id: 'div1',
children: 'Minha primeira div feita com React!'
}
//Cria o elemento usando as props
const novaDiv = React.createElement('div', props)
//Coloca a nova div dentro da div "root"
// ReactDOM.render(novaDiv, root)
let parag = React.createElement('p', {
children: 'Parágrafo React',
style: {color: 'orange'}
})
// ReactDOM.render(parag, root)
let divTeste = React.createElement('div', null, 'Div de teste')
const container = React.createElement('div', null, [novaDiv, parag, divTeste])
ReactDOM.render(container, root)
</script>
</body>
</html>