Framework/React ์™„๋ฒฝ ๊ฐ€์ด๋“œ

[React ์™„๋ฒฝ ๊ฐ€์ด๋“œ] section 7 : ๋ฆฌ์•กํŠธ ์•ฑ ๋””๋ฒ„๊น… ํ•˜๊ธฐ

yuri lee 2022. 9. 20. 21:59
๋ฐ˜์‘ํ˜•
์ด ๊ธ€์€ udemy์˜ React ์™„๋ฒฝ ๊ฐ€์ด๋“œ with Redux, Next.js, TypeScript ๊ฐ•์ขŒ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์ •๋ฆฌํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.

91. ๋ชจ๋“ˆ ์†Œ๊ฐœ 

  • Debugging React Apps
  • Finding & Fixing Errors
  • Understanding Error Messages
  • Debugging & Analyzing React Apps
  • Using the React DevTools

92. ๋ฆฌ์•กํŠธ ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€ ์ดํ•ดํ•˜๊ธฐ 

  • ์Šค์Šค๋กœ ์˜ค๋ฅ˜๋ฅผ ์ดํ•ดํ•˜๊ณ  ํ•ด๊ฒฐํ•ด์•ผ ํ•œ๋‹ค. 
  • ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ์†Œ์Šค์ฝ”๋“œ๋ฅผ ์‚ดํŽด๋ณด๊ณ , ์–ด๋””์„œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋Š”์ง€ ๊ทธ ์ค„์ด๋‚˜ ํŒŒ์ผ์„ ์‚ดํŽด๋ด๋ผ. ๊ทธ๋Ÿฌ๋ฉด ๋Œ€๋ถ€๋ถ„์˜ ์˜ค๋ฅ˜๋“ค์€ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค
Failed to compile.

./src/App.js
SyntaxError: /Users/yuri/workplace/best-react/section-07/01-starting-project/src/App.js: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (43:6)

  41 |         <CourseInput onAddGoal={addGoalHandler} />
  42 |       </section>
> 43 |       <section id="goals">
     |       ^
  44 |         {content}
  45 |       </section>
  46 |

 ์˜ˆ๋ฅผ ๋“ค์–ด ๋‹ค์Œ์˜ ์˜ค๋ฅ˜์—์„œ๋Š” ์ปดํŒŒ์ผ์— ์‹คํŒจํ–ˆ๋‹ค๊ณ  ๋‚˜์˜จ๋‹ค. 43๋ฒˆ์งธ ์ค„์˜ 7๋ฒˆ์งธ ์—ด

→ ํ•˜๋‚˜์˜ return ๋ฌธ ์•ˆ์— ๋ช…๋ น๋ฌธ 2๊ฐœ๋ฅผ ๋‚˜๋ž€ํžˆ ๊ฐ€์งˆ ์ˆ˜ ์—†๋‹ค

 

93. ์ฝ”๋“œ ํ๋ฆ„ ๋ฐ ๊ฒฝ๊ณ  ๋ถ„์„

  const addGoalHandler = (enteredText) => {
    setCourseGoals((prevGoals) => {
      const updatedGoals = [...prevGoals];
      updatedGoals.unshift({ text: enteredText, id: "goal1" });
      return updatedGoals;
    });
  };

→ ๊ฐœ๋ฐœ์ž ๋„๊ตฌ์˜ console.log ๋ฅผ ๋ณด๋ฉด ๋œ๋‹ค. ๋ธŒ๋ผ์šฐ์ €๋Š” ์šฐ๋ฆฌ๊ฐ€ ์ฝ”๋“œ์— ์ถ”๊ฐ€ํ•œ ๋กœ๊น… ๋ฉ”์‹œ์ง€๋“ค์„ ๋ณด์—ฌ์ค€๋‹ค. ์—ฌ๊ธฐ์„œ ๊ฒฝ๊ณ  ๋ฉ”์‹œ์ง€๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. (goal1์ด๋ผ๋Š” ๊ฐ™์€ ํ‚ค๋ฅผ ๊ฐ€์ง„ 2๊ฐœ์˜ children ์ด ์กด์žฌํ•œ๋‹ค๋Š” ์˜๋ฏธ)

94. ์ค‘๋‹จ์  (breakpoint) ์ž‘์—…ํ•˜๊ธฐ 

  • ๊ฐœ๋ฐœ์ž ๋„๊ตฌ > Source ํƒญ์•  ๋“ค์–ด๊ฐ€๋ฉด ํ˜„์žฌ ์›น ํŽ˜์ด์ง€์—์„œ ์‚ฌ์šฉ ์ค‘์ธ ์†Œ์Šค ํŒŒ์ผ์„ ์ฐพ์•„๋ณผ ์ˆ˜ ์žˆ๋‹ค. js ํŒŒ์ผ๋„ ํฌํ•จ๋˜์–ด ์žˆ๋‹ค. 
  • ๋ฆฌ์•กํŠธ ๊ฐœ๋ฐœ ๊ณผ์ •์—์„œ ์‹คํ–‰๋˜๋Š” npm start ์Šคํฌ๋ฆฝํŠธ๋Š” ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ฝ”๋“œ๋ฅผ ๋ณด๋‚ด์„œ ์‹คํ–‰๋  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๊ณ , ๋˜ํ•œ ๋ธŒ๋ผ์šฐ์ €์—๊ฒŒ ์ถ”๊ฐ€์ ์ธ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•ด์„œ ๋ธŒ๋ผ์šฐ์ € ๊ฐœ๋ฐœ์ž ๋„๊ตฌ๊ฐ€ ์šฐ๋ฆฌ๊ฐ€ ์ž‘์„ฑํ•œ ์ฝ”๋“œ๋ฅผ ๋””๋ฒ„๊ทธํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ค€๋‹ค. ์‹ฌ์ง€์–ด ๊ทธ ์ฝ”๋“œ๊ฐ€ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ œ๋Œ€๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š๋”๋ผ๋„! 
  • ์ด๋Ÿฌํ•œ ๋ฆฌ์• ํŠธ ๊ฐœ๋ฐœ ๊ณผ์ •์€ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์‹คํ–‰๋˜๋Š” ์ฝ”๋“œ์™€ ์šฐ๋ฆฌ๊ฐ€ ์ž‘์„ฑํ•œ ์ฝ”๋“œ ์‚ฌ์ด์—์„œ ๋ธŒ๋ฆฟ์ง€ ์—ญํ• ์„ ํ•œ๋‹ค. 



CourseGoalItem์— ๊ฐ€๋ฉด, deletehandler๊ฐ€ ์žˆ๋‹ค. ์ถ”๊ฐ€ํ•˜๊ณ  ์‹ถ์€ ์ค„์„ ํด๋ฆญํ•ด์„œ ์ค‘๋‹จ์ ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค.  ์ดํ›„ Steop over next , Step into next function, Resume ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ๋‹จ๊ณ„์ ์œผ๋กœ ์‚ดํŽด๋ณผ ์ˆ˜ ์žˆ๋‹ค. 

95. ๋ฆฌ์•กํŠธ DevTools ์‚ฌ์šฉํ•˜๊ธฐ 

  • we see the actual React Components and the Components structure


https://www.udemy.com/course/best-react/

๋ฐ˜์‘ํ˜•