[React] React๊ธฐ์ดˆ

hyojeongยท2021๋…„ 10์›” 12์ผ
0

๋ฐ๋ธŒ์ฝ”์Šค

๋ชฉ๋ก ๋ณด๊ธฐ
47/50
post-thumbnail

๐Ÿ“šTIL

day41

React

  • View๋งŒ ๊ด€๋ฆฌํ•˜๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ ๋‹ค๋ฅธ ๋ถ€๋ถ„์€ ์ฑ…์ž„์ง€์ง€ ์•Š์Œ
  • react๋Š” ์ปดํฌ๋„ŒํŠธ์˜ ์กฐํ•ฉ์œผ๋กœ View๋ฅผ ๊ตฌ์„ฑํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ปดํฌ๋„ŒํŠธ๋Š” react์˜ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์š”์†Œ
  • ๊ฐ€์ƒ๋”์„ ์‚ฌ์šฉํ•˜์—ฌ ํ•„์š”ํ•œ ๋ถ€๋ถ„๋งŒ ํ•œ๋ฒˆ์— ๋ Œ๋”๋งํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ตœ์ ํ™” ์—†์ด ๋น ๋ฅธ ์„ฑ๋Šฅ์„ ๋‚ผ ์ˆ˜ ์žˆ์Œ

JSX

  • class -> className : class๊ฐ€ ์ด๋ฏธ JS๋‚ด์—์„œ ์˜ˆ์•ฝ์–ด๊ธฐ ๋•Œ๋ฌธ์— class ์ด๋ฆ„์„ ์ง€์ •ํ•  ๋•Œ className ์‚ฌ์šฉ
  • ๋ฐ˜๋“œ์‹œ ์ตœ์ƒ์œ„ ์š”์†Œ๋Š” ํ•˜๋‚˜์—ฌ์•ผ ํ•จ
  • ์ตœ์ƒ์œ„ ์š”์†Œ๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ์•ผ ํ•  ๊ฒฝ์šฐ ๋‹ค๋ฅธ ์š”์†Œ๋กœ ๊ฐ์‹ธ๊ฑฐ๋‚˜ fregment๋กœ ๊ฐ์‹ธ๊ธฐ

์กฐ๊ฑด๋ฌธ & ๋ฐ˜๋ณต๋ฌธ

  • ์กฐ๊ฑด๋ฌธ
const str = "Hello React"
const showLink = false

{showLink && (	//showLink๊ฐ€ true์ผ ๊ฒฝ์šฐ ์ถœ๋ ฅ
  <a
     classList = "App-link"
     href = "https://reactjs.org"
     >	Learn {str}  </a>
)}
  • ์‚ผํ•ญ์—ฐ์‚ฐ์ž
const showLogo = "show"

{showLogo === "show" ? 
  <img src="./logo.svg" alt="logo">
  :	<h1>React</h1>
}
  • ๋ฐ˜๋ณต๋ฌธ
const libraries = ['React', 'Vue', 'Angular']

<ul>
  {
    libraries.map(library => (
      <li key={library}>{library}</li>
    ))
  }
</ul>

์ปดํฌ๋„ŒํŠธ

  • react ์ปดํฌ๋„ŒํŠธ์— html, style, javascript๋ฅผ ๋‹ด์„ ์ˆ˜ ์žˆ์Œ
  • event, state(์ƒํƒœ)๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ์Œ
  • ๋ฐ์ดํ„ฐ๋Š” ์ƒ์œ„์—์„œ ์•„๋ž˜๋กœ ํ๋ฅด๋Š” ๋‹จ๋ฐฉํ–ฅ ๋ฐ์ดํ„ฐ
  • ๋งŽ์€ ์ปดํฌ๋„ŒํŠธ๋“ค์ด ๋ชจ์—ฌ์„œ App์„ ๋งŒ๋“ฆ
  • ์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ UI๋ฅผ ์ถ”์ƒ์ ์œผ๋กœ ๋ฐ”๋ผ๋ณด๊ธฐ
  • ์ปดํฌ๋„ŒํŠธ ๋ถ„๋ฅ˜ : ๋„๋ฉ”์ธ/ ์—ญํ• / ํฌ๊ธฐ

๐ŸŽจ2021. 10. 12

์˜ค๋Š˜ ๋“œ๋””์–ด ๋ฆฌ์•กํŠธ ์ฒซ ๊ฐ•์˜๋ฅผ ๋“ค์—ˆ๋‹ค! ๋ทฐ๋ณด๋‹ค ๋ฆฌ์•กํŠธ๊ฐ€ ์–ด๋ ต๋‹ค๋Š” ์–˜๊ธฐ๋ฅผ ๋งŽ์ด ๋“ค์—ˆ๋Š”๋ฐ ์ฒ˜์Œ ๋ดค์„ ๋•Œ JSํŒŒ์ผ์— ์žˆ๋Š” html ๊ตฌ์กฐ์ธ JSX๋ฅผ ๋ณด๊ณ  ๋ทฐ๋ž‘ ๋น„์Šทํ•˜๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค. ์ปดํฌ๋„ŒํŠธ๋ฅผ ์งค ๋•Œ ๋ณดํ†ต ๋„๋ฉ”์ธ์— ๋”ฐ๋ผ์„œ ๋ถ„๋ฅ˜ํ–ˆ๋Š”๋ฐ ๊ทธ ์™ธ์˜ ๋ฐฉ์‹๋“ค์ด ์žˆ๋‹ค๋Š” ์‚ฌ์‹ค์„ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ค. ์•ž์œผ๋กœ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์งค ๋•Œ ์ž˜ ์ ์šฉํ•ด๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค. ์•„์ง ๊ธฐ์ดˆ์— ๊ธฐ์ดˆ๋งŒ ๋ฐฐ์›Œ์„œ ์ •ํ™•ํ•˜๊ฒŒ ํŒŒ์•…ํ•˜์ง€ ๋ชปํ–ˆ๋Š”๋ฐ ์–ผ๋ฅธ ๊ฐ•์˜๋ฅผ ๋“ฃ๊ณ  ๊ณต๋ถ€ํ•ด๋ด์•ผ๊ฒ ๋‹ค.
๋‚ด์ผ์€ ์ •๋ง ๋ฆฌ์—‘ํŠธ ๊ฐ•์˜์— ๋ชจ๋“  ์‹œ๊ฐ„์„ ์‚ฌ์šฉํ•ด์•ผ๊ฒ ๋‹ค!

profile
Front-end Develop๐Ÿฅฐ

0๊ฐœ์˜ ๋Œ“๊ธ€