๋ฐ์ํ
[์ถ์ฒ : Youtube - ์ํ์ฝ๋ฉ]
https://youtu.be/pPCC2JWbPgk?list=PLuHgQVnccGMCRv6f8H9K5Xwsdyg4sFSdi
Subject ํด๋์ค๋ฅผ ๋ฆฌํฉํ ๋ง ํด์ค๋ค.
import './App.css';
import React, { Component } from 'react';
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>HTML</h2>
HTML is HyperText Markup Language.
</article>
);
}
}
class App extends Component {
render() {
return (
<div className="App">
<Subject title="WEB" sub="world wide web!"></Subject>
<TOC></TOC>
<Content></Content>
</div>
);
}
}
export default App;
Subject๋ฅผ ํ ์ค ๋ ์ถ๊ฐํด๋ณธ๋ค.
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></Content>
</div>
);
}
}
Content ํด๋์ค๋ Subject ํด๋์ค์ฒ๋ผ ๋ฆฌํฉํ ๋ง ํด์ค๋ค.
import './App.css';
import React, { Component } from 'react';
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="HTML" desc="HTML is HyperText Markup Language."></Content>
</div>
);
}
}
export default App;
๋ฐ์ํ
'JavaScript > React' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์ํ์ฝ๋ฉ-React] State ์ฌ์ฉ (0) | 2021.05.29 |
---|---|
[์ํ์ฝ๋ฉ-React] Component ํ์ผ๋ก ๋ถ๋ฆฌํ๊ธฐ (0) | 2021.05.29 |
[์ํ์ฝ๋ฉ-React] ์ปดํฌ๋ํธ ๋ง๋ค๊ธฐ 2 (0) | 2021.05.28 |
[์ํ์ฝ๋ฉ-React] ์ปดํฌ๋ํธ ๋ง๋ค๊ธฐ 1 (0) | 2021.05.28 |
[์ํ์ฝ๋ฉ-React] ๋ฆฌ์กํธ๊ฐ ์๋ค๋ฉด (0) | 2021.05.28 |
๋๊ธ