index.html ํ์ผ์
์ด root ๋ index.html ํ์ผ๊ณผ index.js ํ์ผ ๋๊ฐ ์๋ก ๊ฐ์์ผ ํ๋ค. ๋ฌผ๋ก ๊ผญ root ๊ฐ ์๋๋๋ผ๋ ๋๋ค.
๋๊ฐ๊ฐ ๊ฐ์ id ๋ฅผ ๊ฐ์ง๊ณ ์์ผ๋ฉด ok!
1. localhost ๋ฅผ ๊ฒ์ ์ ์งํ๊ณ refresh ํ ์ ์๊ณ , ๊ทธ๊ฑธ ๋ณด๋ ค๋ฉด npm start ๋ฅผ ์คํํ๊ณ console์ ์ข ๋ฃํ์ง ์์์ผํ๋ค.
2.react ๋ ์์ค์ฝ๋์ ์ฒ์๋ถํฐ html ์ ๋ฃ์ง ์๋๋ค.
html ์์ html ์ ์ถ๊ฐํ๊ฑฐ๋ ์ ๊ฑฐํ๋ ๋ฒ ์ ์๊ณ ์๋ค.
3. <App />์ html ์ด ์๋๋ค. component ์ด๋ค.
component ๋ html ์ ๋ฐํํ๋ ํจ์. => <App/>์ html์ ๋ฐํํ๋ ํจ์! ์ด๋ค.
* react ๋ component ์ ํจ๊ป ๋์ํจ. ๋ชจ๋ ๊ฒ์ด component ์ด๋ฉฐ, component ๊ฐ data ๋ฅผ ๋ณด์ฌ์ค.
4. jsx : js ๋ฅผ ํ์ฅํ ๋ฌธ๋ฒ, JS์์ HTML,JS์ ๋ชจ๋ ๊ธฐ๋ฅ ํฌํจ! ,์ฆ, html js ์ฌ์ด์ ์ด๋ฌํ ์กฐํฉ์ jsx
JSX๋ react์์ ๋์จ ๋งค์ฐ customํ ์ ์ผํ ๊ฐ๋ ์ด๋ค. ๋๋จธ์ง๋ ๋ค JS๋ฅผ ์ฌ์ฉํจ.
-jsx ์ ๋ํ ๊ฐ๋ ์ ๋ค๋ฅธ ๋ถ์ผ๋ก ๊ฐ๋ฉด ์ฌ์ฉ๋ชปํจ
5. component ๋ฅผ ๋ง๋๋ ๋ฐฉ๋ฒ? : component ๋ฅผ ์์ฑํ ๋๋ง๋ค import React from 'react'; ๋ฅผ ์จ์ค์ผ๋ง ํ๋ค.
๋ง์ฝ ์ฐ์ง ์๋๋ค๋ฉด, react ๋ ์ฌ๊ธฐ์ JSX๊ฐ ์๋ component ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ์ดํดํ์ง ๋ชปํจ.
6.react application์ ํ๋ฒ์ ํ๋์ component ๋ง rendering ํ ์ ์๋ค.=> ์ด์ ์ฌ๋ฌ ์ปดํฌ๋ํธ๋ฅผ ๋ ๋๋ง์ด ๊ฐ๋ฅํ๋ค๊ณ ํจ.
์ด๋ ๊ฒ ํ๋๋ฐ ์ค๋ฅ๊ฐ ๋ธ... ๋ญ์ง???
( ํน์...๋ ๋๋ง ์ฌ๋ฌ๊ฐ ํ๋๋ฒ ์์๋๋ถ~~)
=> ๋ฐ๋ผ์ ๋ชจ๋ ๊ฒ์ application ์ฆ, App.js ์์ ๋ค์ด๊ฐ์ผ๋ง ํจ.
index.js
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import Potato from './Potato'; ReactDOM.render(<App/>, document.getElementById('root'));โ
Potato.js
import React from 'react'; function Potato(){ return( <h3> i love potato </h3> ) } export default Potato;
App.js
import React from 'react'; import Potato from './Potato'; function App() { return ( <div className="App"> <h1>hello!!</h1> <Potato/> </div> ); } export default App;
์๋๋ git ์ผ๋ก ์ฐ๋ํ๋ ๊ณผ์ ์์?
์๋ฌ๊ฐ ๋ฐ์ํ์ฌ ์ค๋ฅํด๊ฒฐ๋ฐฉ๋ฒ์ ์ฐพ๋ค๊ฐ ์๋ ๋ธ๋ก๊ทธ๋ฅผ ํตํด ํด๊ฒฐํจ. ์ฐธ๊ณ ํ๊ธฐ ๋ฐ๋.
Git requested URL returned Error 403 ํด๊ฒฐ๋ฐฉ๋ฒ
https://cheonjoosung.github.io/blog/git-push-error
'React ์๋ฆฌ์ฆ๐ > ReactJS๋ก ์ํ ์น ์๋น์ค ๋ง๋ค๊ธฐ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ฟReactJS๋ก ์ํ ์น ์๋น์ค ๋ง๋ค๊ธฐ - ํ๊ธฐ๐ฟ (6) | 2021.08.21 |
---|---|
๐ฟ์ค๋ ๊ณต๋ถํ ๊ฒ (์ ๋ฆฌ x)๐ฟ (0) | 2021.08.20 |
๐ฟReact JS ๋ก ์ํ ์น ์๋น์ค ๋ง๋ค๊ธฐ - #2.1 props ์ ๋ํด (0) | 2021.08.19 |
๐ฟReactJS ๋ก ์ํ ์น ์๋น์ค ๋ง๋ค๊ธฐ - ์ค๋น(์ค์น ๋จ๊ณ)๐ฟ (2) | 2021.08.18 |
๐ฟReact JS ๋ก ์ํ ์น ์๋น์ค ๋ง๋ค๊ธฐ๐ฟ ์์! (0) | 2021.08.18 |