Note
'Installation' ์ฑํฐ๋ ๋ค์๊ณผ ๊ฐ์ ๋ด์ฉ์ ๋ค๋ฃน๋๋ค.
- React๋ฅผ ์๋กญ๊ฒ ์์ํ๊ฑฐ๋ ์ ์ง์ ์ผ๋ก ๋์ ํ๋ ๋ฐฉ๋ฒ
- ๋ฆฌ์กํธ ํ๋ ์์ํฌ ์ค์ Next ๋ถํฐ ์๊ฐ๋๋ ๊ฒ์ด SSR์ด ๋์ธ๊ตฌ๋ ํ๋ ๋๋์ด ๋ค์๋ค.
- npm trends์์๋ Next๊ฐ ์๋์ ์ธ ์ ํ์ ๋ฐ๊ณ ์์. (https://npmtrends.com/gatsby-vs-next-vs-remix)
- ๋ผ์ฐํ
, ๋ฐ์ดํฐ ํธ์ถ, ๋ฒ๋ค๋ง์ฒ๋ผ ์์ด ๋ง์ด ๊ฐ๋ ์ค์ ๋ค์ ํ๋ ์์์ ์ฌ์ฉํจ์ผ๋ก์จ ๊ฐ๋จํ๊ฒ ๊ตฌํํ ์ ์์ ๋ฏ.
As your JavaScript bundle grows with every new feature, you might have to figure out how to split code for every route individually. As your data fetching needs get more complex, you are likely to encounter server-client network waterfalls that make your app feel very slow. As your audience includes more users with poor network conditions and low-end devices, you might need to generate HTML from your components to display content earlyโeither on the server, or during the build time. Changing your setup to run some of your code on the server or during the build can be very tricky. (์ถ์ฒ: https://react.dev/learn/start-a-new-react-project#can-i-use-react-without-a-framework)
- ์๋ ๋ณธ๋ฌธ์ ์ ๋ฆฌ์กํธ ํ๋ ์์์ ์ฌ์ฉํด์ผ ํ๋์ง? ๋ผ๋ ์ง๋ฌด์ ๋ํ ๋ชจ๋ฒ ๋ต์์ด๋ผ๊ณ ์๊ฐ.
React frameworks on this page solve problems like these by default, with no extra work from your side. They let you start very lean and then scale your app with your needs. Each React framework has a community, so finding answers to questions and upgrading tooling is easier. Frameworks also give structure to your code, helping you and others retain context and skills between different projects. Conversely, with a custom setup itโs easier to get stuck on unsupported dependency versions, and youโll essentially end up creating your own frameworkโalbeit one with no community or upgrade path (and if itโs anything like the ones weโve made in the past, more haphazardly designed). (์ถ์ฒ: https://react.dev/learn/start-a-new-react-project#can-i-use-react-without-a-framework)
- ํนํ Next ํ๊ณผ ๊ธด๋ฐํ๊ฒ ๊ฐ๋ฐํ๋ ๊ฒ ๊ฐ๊ณ ์๋ ๋ณธ๋ฌธ์ ๋ดค์ ๋, ์ ์ฐจ ํ์คํ์ผ๋ก ๊ฐ๋ ๊ฒ์ด ๋ฆฌ์กํธ ํ์ ๋น์ ์ผ๋ก ๋ณด์.
Next.jsโs App Router is a redesign of the Next.js APIs aiming to fulfill the React teamโs full-stack architecture vision. It lets you fetch data in asynchronous components that run on the server or even during the build. (์ถ์ฒ: https://react.dev/learn/start-a-new-react-project#nextjs-app-router)
- ์๋ฒ์์ ๊ตฌ๋ํ๋ ์ปดํฌ๋ํธ๋ฅผ ๊ฐ๋จํ ๊ตฌํํ๊ฒ ํด์ค ์๋ก์ด ๊ธฐ๋ฅ
For example, you can write a server-only React component as an async function that reads from a database or from a file. Then you can pass data down from it to your interactive components: (์ถ์ฒ: https://react.dev/learn/start-a-new-react-project#which-features-make-up-the-react-teams-full-stack-architecture-vision)
-
Q. ๋ค๋ฅธ ๋ถ๋ค์ ์ค๋ฌดํ ๋, ๋ฆฌ์กํธ์ ์๋ก์ด ๊ธฐ๋ฅ์ด๋ ๊ด๋ จ ํ๋ ์์ ์ฌ์ฉ ํํฉ์ด ์ด๋ค์ง?
-
A. ํํธ์ฅ ์ฑํฅ์ด ์์ ํ๋(stable) ์๋ก์ด ๊ธฐ๋ฅ์ด ์์ผ๋ฉด ๋ฒ์ ์ ํ๋ ๊ฒ์ด ์ข๋ค๋ ์ฑํฅ์ด๋ผ ์ ํ๋ก์ ํธ ์์ํ๋ฉด ์๋ก์ด ๊ธฐ๋ฅ์ ์ ๊ทน ๋์ ํ๋ ๋ถ์๊ธฐ. ๋ฐ์ดํฐ ํต์ ๋์ด ๋ง์ ๋ฐฑ์คํผ์ค ํ๋ก์ ํธ์์ ๋ฆฌ์กํธ ์๋ฒ ์ปดํฌ๋ํธ๋ฅผ ์ฌ์ฉํด๋ณธ ๊ฒฝํ์ด ์ข์๋ค.
-
A. Gatsby ์ฌ์ฉ ์ค์ธ๋ฐ Next๊ฐ ๋์ธ์ธ ๊ฒ ๊ฐ์ ์ฎ๊ธธ๊น ๊ณ ๋ฏผ์.
-
Q. Gatsby๋ ์ ์ ํ์ด์ง๋ก ๋ ํ๋ก์ ํธ์ ํนํ๋ ๊ฒ์ผ๋ก ์๊ณ ์๋๋ฐ ๋ง๋์ง?
-
A. ๋ฌด์กฐ๊ฑด ์ ์ ํ์ด์ง ์์ฑ ๊ธฐ๋ฅ๋ง ์๋๊ฑด ์๋์ง๋ง ssr์ ์ง์๋์ง ์๋์ง๋ผ ๊ณ ๋ฏผ ์ค์ด๋ค.
-
Remix๋ผ๋ ์ด๋ฆ์ ์ฒ์ ๋ค์ ๊ฒ์ด 2021๋ ์ธ๋ฐ ์ด๋ฒ์ ๊ณต์ ๋ฌธ์์ ๊ด๋ จ ํ๋ ์์์ผ๋ก ๋๋ฒ์งธ์ ์ด๋ฆ์ ์ฌ๋ ค์ ๋๋์. ํ์ง๋ง ์์ง์ ์ค๋ฌด์์ ๋ง์ง ์ฌ์ฉ๋์ง ์๋ ๋ฏ.
-
๋ฆฌ์กํธ์ ํ๋ ์์์ด ์ฌ๋ฌ๊ฐ์ง์ธ ๋งํผ ์ง์ ๊ฒฝํํด๋ณด๊ณ ๋ด๊ฐ ํ๋ ค๋ ์์ ์ ์ ์ ํ ํ๋ ์์์ ์ ํํ๋ ๊ฒ์ด ์ค์ํด ๋ณด์.
- ๋ฆฌ์กํธ ํ๋ ์์ ์์ด๋ ํ๋ก์ ํธ์์ ๋ฆฌ์กํธ๋ฅผ ์ฌ์ฉํ ์ ์๋ค๋ ๊ฒ์ ์ค๋ช ํด์ค ์ฑํฐ.
- ์์ ์ฝ๋์ ๋์จ
import { createRoot } from 'react-dom/client';
๋ถ๋ถ์'react-dom/client'
๋ฅผ ๋ณด๋ฉฐ ๋ฆฌ์กํธ์์ ์๋ฒ ์ชฝ๊ณผ ํด๋ผ์ด์ธํธ ์ชฝ์ผ๋ก ๋๋ ๊ฐ๋ ค๋ ๊ฒฝํฅ์ด ๋ณด์ด๋ ๋ฏ ํ์.
- ์ด์ ๋ฒ์ ์ ๋ฆฌ์กํธ ๋ฌธ์์์๋ vite ๋ง๊ณ webpack์ด ๋์์๋๋ฐ ์ด๋ฒ ์๋ก์ด ๋ฌธ์์์๋ webpack์ด ์์ ์ฌ๋ผ์ง ๊ฒ์ด ์ธ์์ ์.
- ๋ฉํ์์๋ ์ด๋ ๊ฒ ์ฌ์ฉํด์์ด! ๋ผ๋ ๋ฌธ์ฅ์ด ์์๋๋ฐ ๋ฉํ๋ ๋ ๊ฑฐ์ ์ฝ๋๋ ์ด์ฉ ์ ์๊ตฌ๋ ํ๋ ์๊ฐ์ด ๋ค์์. (Thatโs a common way to integrate Reactโin fact, itโs how most React usage looked at Meta for many years!)
- Gatsby๋ง ์ฌ์ฉํ๋ค๊ฐ Next๋ฅผ ๋์
ํด๋ด์ผ๊ฒ ๋ค ์ถ์๋ ์ ์ด ์์์. Gatsby๋ก ํ๋ ์ ์ ๋น๋๋ฅผ Next๋ก๋ ํ๋ ค๊ณ ํ๋ค๊ฐ ๋ชปํ์๋๋ฐ ์ด๋ฒ ์ฑํฐ์ ์์ ์ฝ๋ ์ค์
next export output
์ ๋ฐ๊ฒฌํด์ ๋ค์ ์๋ํด๋ด์ผ๊ฒ ๋ค ์ถ์์. (๊ด๋ จ ๋งํฌ: https://react.dev/learn/add-react-to-an-existing-project#using-react-for-an-entire-subroute-of-your-existing-website)- Next์์ ssr, csr, ssg ๋ค ๊ตฌํ๊ฐ๋ฅํ๋ฉฐ, ์ด ๊ฒฝ์ฐ์ getStaticProps() ํ๋ฒ ์ดํด๋ณด๋ ๊ฒ์ ์ถ์ฒํจ.
- ๋ํ์ ์ธ ์๋ํฐ ์๊ฐ ๋ฐ ์ค์ ์์ ์๊ฐ.
- vim์ ๋งค๋์ ์ธต์ด ์์ด๋ณด์.
- ใ ใ ์ปค์คํ ํ๊ธฐ ์ข์์ ๊ทธ๋ฐ๋ฏ.
- ๋ณดํต ์น๊ฐ๋ฐํ๋ฉด webstorm์ ๋ง์ด ์ฌ์ฉํ๋๋ฐ intelliJ ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๋ ๋ดค๊ณ , ์ ๋ฃ ๋ฒ์ ์ธ ๊ฒฝ์ฐ ์๋ฐ์คํฌ๋ฆฝํธ, ํ์ ์คํฌ๋ฆฝํธ๋ ์ฌ์ฉํ ์ ์๋๋ฐ ํธํ๋ค๊ณ ๋ค์.
- '๋ฆฌํฉํ ๋ง' ์ฑ (๋งํฌ: http://www.yes24.com/Product/Goods/89649360)์์ ์๋ํฐ ๋ง๋ค ์๋ ๋ฆฌํฉํ ๋ง ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ค๋ ๋ด์ฉ์ ๋ณธ ์ ์ด ์๋๋ฐ ์ ๋ฃ ๋ฒ์ ์ ์๋ํฐ๋ค์ ๊ทธ ๊ธฐ๋ฅ์ด ์ข ๋ ๊ฐ๋ ฅํ๋ค๋๋ผ.
- lint ๊ด๋ จ ๊ณ ๋ฏผ๋ค
- lint๋ ๊ณต์ฉ ํจํค์ง๋ฅผ ๋ง๋ค์ด์ ์ฌ์ฉํ๋ ค ํ๋๋ฐ ํ๋ก์ ํธ ๋ง๋ค ์ปค์คํ ํด์ ์ฌ์ฉํ๊ฒ ๋๋๋ฐ ๊ธฐ์ค์ ์ด๋ป๊ฒ ์ ํด์ผ ํ ์ง ๊ถ๊ธํจ.
- ๊ฐ๋ฐ์ ๊ฐ์ธ๋ง๋ค ์ ํธํ๋ ๋ฐฉ์์ด ์์ด์ ์ด๋ ค์ด ๋ฏ. ๊ณต์ฉ ์ปจ๋ฒค์ ์ ๊ฐ์ธ ๊ธฐํธ๋ฅผ ๋ค ๋ฐ์ํ ์ ์์ํ ๋ฐ, ๊ฐ๊ฐ์ธ์ด ๊ณต์ฉ ์ปจ๋ฒค์ ์ ๋ง์ถฐ์ผ ํ๋ ๊ฒ์ธ์ง ๊ฐ์ธ ๊ธฐํธ์ ๋ง๊ฒ ์ปจํธ๋กค ํด๋ ๋๋๊ฑด์ง ๊ณ ๋ฏผ.
- ํผ์ ๊ฐ๋ฐํ๋ ๊ฒฝ์ฐ ํผ์ lint ์ค์ ํ๋ค๋ณด๋ ์ ๋งคํด์ง๋ ๋ถ๋ถ๋..
- ํ๋ก์ ํธ๋ ์ฌ๋ฌ ๊ฐ์ธ๋ฐ ๋ด๋น์๋ ์์ ๋, lint๋ฅผ ์ ์ผ ์ผ๋ฐ์ ์ธ ๊ฑธ๋ก ์ค์ ํด๋๊ณ ์ํฉ์ ๋ง๊ฒ ๋ฐ๊พธ๊ธฐ๋ ํจ. ๋ค๋ง ์ค์ ์ ๋งค๋ฒ ๋ฐ๊พธ๊ธฐ ์ด๋ ค์ฐ๋ ignore ๋ฅผ ์ฌ์ฉํ๊ฒ ๋๋ ๊ฒฝ์ฐ๋..
- Husky๋ก lint ์ค์ ์ ์ ๋ฆฌํ๋๋ก ํ์์. (husky: https://www.npmjs.com/package/husky)
- Husky๋ฅผ ๊ฐ์ด ์ฌ์ฉํ์ง ์์ผ๋ฉด lint๊ฐ ์๋ฏธ ์๋๋ฏ.
- Husky๋ฅผ ์ฌ์ฉํ๋ค ์ฌ์ฉํ์ง ์์ผ๋ ํ๋ก์ ํธ๊ฐ ๋ฌด๋์ง๋ ๋๋...๐ฅบ
- ๋ฆฌ์กํธ ๊ฐ๋ฐ์ ๋์์ฃผ๋ ๋ธ๋ผ์ฐ์ ์ต์คํ ์ ๋ฐ ํจํค์ง ์ค์น์ ๋ํ ์๊ฐ.
- highlight ๋ฅผ ์ฃผ๋ก ์ฌ์ฉํ๊ฒ ๋จ.
- ์ด์๊ฐ ์๊ฒผ์ ๋, highlight๋ก ์ด๋๊ฐ ๋ฌธ์ ์ธ์ง ํ์ธํ๊ธฐ ์ข์.
- ์ํ ๊ด๋ฆฌ๋ debugger๋ console.log๋ก ํ์ธ..
- safari ๋ธ๋ผ์ฐ์ ์์๋ ํจํค์ง๋ฅผ ์ค์นํด์ผ ํ๋ค๋ ๋ด์ฉ์ด ์๋ก์ ์.