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
- CSS
- try.. catch
- FrontendStydy
- 메소드 실행
- callback함수
- this 객체
- frontendstudy
- webProject
- addEventListener
- DOM
- 컴포넌트
- 함수 실행
- 배열메소드
- HTML
- 배열
- 비동기함수
- JavaScript
- 자바스크립트
- 렌더링
- useState
- REACT
- Props
- 리액트
- 이벤트
- typeScript
- input
- 이벤트핸들링
- promise
- Frontend Study
- useRef
Archives
- Today
- Total
이다닷
[React] Day 2 - 컴포넌트 _ props 본문
props 이용법
{this.props.값의 이름}
ex) {this.props.name}
결과 코드
import React, { Component } from 'react';
import './App.css';
class Subject extends Component {
render() {
return (
<header>
<h1>{this.props.title}</h1>
{this.props.sub}
</header>
);
}
}
class TOC extends Component {
render() {
return (
<nav>
<ul>
<li><a href="1.html">HTML</a></li>
<li><a href="2.html">CSS</a></li>
<li><a href="3.html">Javascript</a></li>
</ul>
</nav>
);
}
}
class Content extends Component {
render() {
return (
<article>
<h2>{this.props.title}</h2>
{this.props.desc}
</article>
);
}
}
class App extends Component {
render() {
return (
<div className="App">
<Subject title="WEB" sub="world wide web!"></Subject>
<Subject title="React" sub="For UI"></Subject>
<TOC></TOC>
<Content title="WEB" desc="HTML is HyperText Markup Language"></Content>
</div>
);
}
}
export default App;
결과 사진

chrome 웹 스토어 - react developer tools 사용
