React, Quick Start 빠른 시작
2024. 12. 2. 13:26ㆍ웹 개발
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Add React in One Minute</title>
</head>
<body>
<h2>Add React in One Minute</h2>
<p>This page demonstrates using React with no build tooling.</p>
<p>React is loaded as a script tag.</p>
<!-- We will put our React component inside this div. -->
<div id="like_button_container"></div>
<!-- Load React. -->
<!-- Note: when deploying, replace "development.js" with "production.min.js". -->
<script src="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin></script>
<!-- Load our React component. -->
<script src="like_button.js"></script>
</body>
</html>
like_button.js
"use strict";
const e = React.createElement;
class LikeButton extends React.Component {
constructor(props) {
super(props);
this.state = { liked: false };
}
render() {
if (this.state.liked) {
return "You liked this.";
}
return e(
"button",
{ onClick: () => this.setState({ liked: true }) },
"Like"
);
}
}
const domContainer = document.querySelector("#like_button_container");
const root = ReactDOM.createRoot(domContainer);
root.render(e(LikeButton));
https://ko.legacy.reactjs.org/docs/add-react-to-a-website.html#add-react-in-one-minute
https://codepen.io/pen?&editors=0010&layout=left
https://codesandbox.io/p/sandbox/new?file=%2Fsrc%2FApp.js
https://stackblitz.com/edit/react-ftnxka?file=src%2FApp.js
출처
'웹 개발' 카테고리의 다른 글
React, 리액트 함수 컴포넌트 합성, Comment List (1) | 2024.12.02 |
---|---|
React, Virtual Dom 특성 예제, Clock (0) | 2024.12.02 |
React, JSX 코드 작성해보기 (1) | 2024.12.02 |
npx 실행 시 PSSecurityExcption 에러 발생 시 대응 (0) | 2024.12.02 |
Supabase 따라하기 (0) | 2024.11.29 |