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 | 31 |
Tags
- Frontend Study
- HTML
- 이벤트핸들링
- JavaScript
- addEventListener
- useRef
- useState
- 리액트
- input
- 컴포넌트
- DOM
- 자바스크립트
- callback함수
- REACT
- CSS
- 배열
- 배열메소드
- 비동기함수
- try.. catch
- Props
- typeScript
- 렌더링
- frontendstudy
- 메소드 실행
- promise
- webProject
- 이벤트
- FrontendStydy
- 함수 실행
- this 객체
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 사용