-
Notifications
You must be signed in to change notification settings - Fork 0
/
index10-3.html
59 lines (47 loc) · 1.54 KB
/
index10-3.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
54
55
56
57
58
59
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="react.development.js" ></script>
<script src="react-dom.development.js" ></script>
<script src="babel.min.js" ></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
//babel
//1-jsx ---> React.createElement
//2-<ES6 --> ES5
//JSX javascript,html React.createElement
//React.createElement(tagname, attrebites-object, children)
function changeNameToUpperCase(input){
return input.toUpperCase();
}
const names = ["ali","reza","maryam","morad","kamran"]
const listItems = names.map((item,index)=><React.Fragment key={index}>
<li >
{changeNameToUpperCase(item)}
</li>
<span>
😂
</span>
</React.Fragment>)
const ul = <ul>
{listItems}
</ul>
const firstDiv = <div style={{
backgroundColor:'red',
height:'100px',
width:'200px'
}} id="my-first-div" sssad="ads" >{ul}</div>
//Component functions that returns JSX
console.log(firstDiv);
//ReactDOM.render(element, container)
ReactDOM.render(
firstDiv,
document.getElementById('root')
);
</script>
</body>
</html>