index.js
์App.js
๋๊ฐ์ง ํ์ผ์ด ์๋ค.
App.js
๋ ์ปดํฌ๋ํธ๋ฅผ ๋ง๋๋ ํจ์๊ฐ ๋ค์ด์๋ค
index.js
๋ App.js์์ ํจ์๋ฅผ import๋ก ๊ฐ์ ธ์์ ํ๋ฉด์ ๋ ๋๋งํด์ค๋ค.
App.js
import React from 'react';
import './style.css';
function App() {
return (
<div>
<h1>Hello !</h1>
<p>Start editing to see some magic happen :)</p>
</div>
);
}
export default App;
index.js
const rootElement = document.getElementById('root');
const root = createRoot(rootElement)
root.render(<App />)
import React, { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
const rootElement = document.getElementById('root');
//html์ <div id='root'></div>๊ฐ ์๋ค. ์์๋ฃ์ด์ค์ผํ๋ค.
const root = createRoot(rootElement);
root.render(<App />);
function GreetingJsx({ name }) {
return <h1>hello~!{name}</h1>;
//๋ง์ฝ return ๊ฐ์ด ์ฌ๋ฌ์ค์ด๋ฉด ()์ ๊ฐ์ธ์ฃผ๊ธฐ
}
function App() {
return React.createElement(
GreetingJsx, { name: 'ํฌ๋กฑ' }
)
}
export default App;
import App from './App';
const rootElement = document.getElementById('root');
const root = createRoot(rootElement);
root.render(<App />);
function App()์์
์ปดํฌ๋ํธ<Header />
์์ title='๋ฆฌ์กํธ' ๋ผ๊ณ ๋์ด์๋ค.
์ด title='๋ฆฌ์กํธ'
๊ฐ Header ์ปดํฌ๋ํธ ํจ์์ ์ธ์props
๋ก ๋ค์ด๊ฐ๊ฒ๋จ.
์ฝ์ ๋ก๊ทธ๋ ๊ฒฐ๊ณผ๋ฅผ ์ดํด๋ณด๋ฉด
props
๋object
์ด๋ค.
const topics ๊ฐ ๋ฐฐ์ด์ด๋ฏ๋ก
Nav(props) ์์ props๋ก ๋ค์ด๊ฐ topics๋ object์ ๋ฐฐ์ด
topics๋ key๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค!