코드네임 :
React - 1 본문
JS에서는 HTML을 먼저 만들고 그걸 javascript로 가져와서 수정하는 식이었으나
ReactJS는 모든걸 javascript로 먼저 시작한다
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div id="root"></div>
</body>
<script type="text/babel">
const root = document.getElementById("root");
const Title = () => (
<h3 id="title" onMouseEnter={() => console.log("mouse entered")}>
Hello title
</h3>
);
const Button = () => (
<button
style={{ backgroundColor: "tomato" }}
onClick={() => console.log("im Clicked")}
>
Click me
</button>
);
//const container = React.createElement("div", null,[Title, button]);
const Container = () => (
<div>
<Title />
<Button />
</div>
);
ReactDOM.render(<Container/>, root);
</script>
</html>
'🖥️Frontend > React' 카테고리의 다른 글
React -2 (0) | 2025.03.11 |
---|