Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 자식결합자
- 아두이노
- sub태그
- not 의사클래스
- html 태그
- background-color 속성
- i 태그
- 임베디드
- height속성
- sup태그
- iframe 태그
- go live
- html
- padding 속성
- br 태그
- iframe
- css
- Live Server
- reveal in file explorer
- 인접 형제 결합자
- id 선택자
- Checked 의사 클래스
- width속성
- RGBA
- html tag i
- focus 의사클래스
- 일반 형제 결합자
- 전체 선택자
- RGB
- tag html
Archives
- Today
- Total
so woon!
[React] render 본문
학습일 : 2023. 03. 06
<!DOCTYPE html>
<html>
<body>
<div id="root"></div>
</body>
<script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@17.0.2/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");
let counter = 0;
// 카운트업 함수
function countUp() {
counter = counter + 1;
render(); // 함수 호출 (UI 바로 반영을 위함)
}
// 랜더 함수를 따로 생성 => 위에서 호출할 용도
function render() {
ReactDOM.render(<Container />, root);
}
const Container = () => (
<div>
<h3>Total Clicks : {counter}</h3>
<button onClick={countUp}>Click Me</button>
</div>
);
render();
</script>
</html>
UI 에 바로 반영을 하기 위해서
랜더 render();
를 따로 해주지 않고 더 편리한 방법이 있다고 하는데
그게 무엇일지?
카운트업 함수 생성 후 UI에 바로 반영하기
'ReactJS > 개념정리' 카테고리의 다른 글
[React] Inputs, State (0) | 2023.03.11 |
---|---|
[React] State 바꾸기 (0) | 2023.03.07 |
[React] 리렌더링 (0) | 2023.03.07 |
[React] React.useState 사용하기 (0) | 2023.03.06 |
[React] JSX (0) | 2023.03.05 |
Comments