-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
45 lines (41 loc) · 1.27 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<body>
<div id="root"></div>
</body>
<script src="https://unpkg.com/react@18.2.0/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel">
const root = document.getElementById("root");
/* JSX문법 - React element 생성 */
// function ...(){return ();} : arrow function와 동일 의미
function Title() {
return (
<h3 id="title" onMouseEnter={() => console.log("mouse enter")}>
Hello I'm a JSX
</h3>
);
}
// arrow function : ()=>으로 함수화 시킴
const Button = () => (
<button
style={{
backgroundColor: "tomato",
}}
onClick={() => console.log("I am clicked")}
>
"Click me"
</button>
);
const Container = () => (
// 컴포넌트 첫글자 반드시 대문자. 소문자일 경우 html태그로 인식
// 생성된 React Element는 원하는 만큼 사용 가능 => 동일코드 재사용
<div>
<Title />
<Button />
</div>
);
ReactDOM.render(<Container />, root);
</script>
</html>