๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
React ์‹œ๋ฆฌ์ฆˆ๐ŸŒ/ReactJS๋กœ ์˜ํ™” ์›น ์„œ๋น„์Šค ๋งŒ๋“ค๊ธฐ

๐ŸฟReact JS ๋กœ ์˜ํ™” ์›น ์„œ๋น„์Šค ๋งŒ๋“ค๊ธฐ - JSX? ์ปดํฌ๋„ŒํŠธ?๐Ÿฟ

by @ENFJ 2021. 8. 18.

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