async Server Component์์ ๋ฐ์ดํฐ๋ฅผ fetching ํ ๋ ๋๋ ์๋ฌ.
์ด ๋ฌธ์ ๋ TypeScript๊ฐ async Component๋ฅผ ์ดํดํ์ง ๋ชปํด ๋ฐ์ํ๋ ๋ฌธ์ ์ด๋ค.
Server Side Rendering ์ฌ์ฉ์ค์, next 13์ ๊ธฐ๋ณธ ํ์ด์ง์ธ page.tsx๋ client side rendering ์ด ๋ถ๊ฐ๋ฅํด,
๋ฐ๋ก component๋ฅผ ๋นผ์ ์์ ํ ํ, page.tsx์ ๋ถ์๋๋ ์ด๋ฐ ์๋ฌ๊ฐ ๋ฌ๋ค.
์ปดํฌ๋ํธ ๊ฐ์ ธ์ฌ ๋ ๋๋ ์๋ฌ๋ ์ฒ์์ด์ด์.. ์ ์๋์ง ใ ใ ํ๋ค๊ฐ chat GPT๋ ์ด๋ฐ ๋ต์ ์ฃผ์๋ค.
โ ๏ธ ์๋
์ค๋ฅ ๋ฉ์์ง๋ JSX์์ 'ChannelTab'์ด๋ผ๋ ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ๋ ค๊ณ ํ์ง๋ง ๋ฐํ ์ ํ์ด ์ ํจํ React ์์๊ฐ ์๋ Promise <Element> ์ด๋ฏ๋ก ์ ํจํ JSX ์์๊ฐ ์๋์ ๋ํ๋ ๋๋ค.
JSX๋ ์ผ๋ฐ์ ์ผ๋ก ์ ํ(๊ตฌ์ฑ ์์ ๋๋ HTML ์์)๊ณผ props(์์ฑ)๋ก ๊ตฌ์ฑ๋๋ ์ ํจํ React ์์๋ฅผ ๋ฐํํ๋ ๊ตฌ์ฑ ์์๋ฅผ ๊ธฐ๋ํฉ๋๋ค. ๊ทธ๋ฌ๋ ์ด ๊ฒฝ์ฐ 'ChannelTab' ๊ตฌ์ฑ ์์๊ฐ ๋์ Promise <Element>๋ฅผ ๋ฐํํ๋ ๊ฒ์ผ๋ก ๋ณด์ ๋๋ค .
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ค๋ฉด 'ChannelTab' ๊ตฌ์ฑ ์์๊ฐ ์ฝ์์ด ์๋ ์ ํจํ JSX ์์๋ฅผ ๋ฐํํ๋์ง ํ์ธํด์ผ ํฉ๋๋ค. Promise๋ ์ผ๋ฐ์ ์ผ๋ก API์์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๋ ๊ฒ๊ณผ ๊ฐ์ ๋น๋๊ธฐ ์์ ์ ์ฒ๋ฆฌํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
๋น๋๊ธฐ์ ์ผ๋ก ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค๊ณ ์ฝ์์ด ํ์ธ๋ ํ ๊ตฌ์ฑ ์์๋ฅผ ๋ ๋๋งํ๋ ค๋ ๊ฒฝ์ฐ ์ํ ๋ณ์ ๋๋ Redux ๋๋ React Query์ ๊ฐ์ ์ํ ๊ด๋ฆฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ฌ ์ฝ์์ ์ฒ๋ฆฌํ๊ณ ํ์ธ๋ ๋ฐ์ดํฐ๋ก ๊ตฌ์ฑ ์์์ ์ํ๋ฅผ ์ ๋ฐ์ดํธํ ์ ์์ต๋๋ค.
โํด๊ฒฐ
๊ตฌ๊ธ์ ๋ค์ง๋ค๊ฐ https://github.com/vercel/next.js/issues/42292 ์ด ๊ณณ์ ๋๋ฌํ๊ณ ,
'SomeComponent' cannot be used as a JSX component. · Issue #42292 · vercel/next.js
Verify canary release I verified that the issue exists in the latest Next.js canary release Provide environment information Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binar...
github.com
๊ทธ๋์ Next.js ๊ณต์๋ฌธ์๋ฅผ ๋ค์ ธ๋ณด์๋ค.
Next.js ๊ณต์ ๋ฌธ์์์๋ ์๋์ ๊ฐ์ด Component ์์ ํ ์ค์ ์ฝ๋๋ฅผ ์ถ๊ฐํ๋ผ๊ณ ํ์๋ค. ์์ง ํด๊ฒฐ ์ค์ธ๊ฐ..
{/* @ts-expect-error Async Server Component */}
import { ExampleAsyncComponent } from './ExampleAsyncComponent';
export default function Page() {
return (
<>
{/* @ts-expect-error Async Server Component */}
<ExampleAsyncComponent />
</>
);
}
https://nextjs.org/docs/app/building-your-application/configuring/typescript#async-server-component-typescript-error
Configuring: TypeScript | Next.js
Next.js provides a TypeScript-first development experience for building your React application. It comes with built-in TypeScript support for automatically installing the necessary packages and configuring the proper settings. ๐ฅ Watch: Learn about the b
nextjs.org
'์ฝ๋ฉ ๋ฉ๋ชจ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[error] Encountered two children with the same key ~ (feat. ์ค๋ณต ์ ๊ฑฐ) (1) | 2023.06.21 |
---|---|
border line ์์ผ๋ก ์ค์ ํ๊ธฐ (0) | 2023.06.19 |
ECMAScript 2023 (5) | 2023.05.30 |
[error] key๊ฐ์ ๋ฃ์ด์ฃผ์ง ์์ ์๊ธฐ๋ ์ค๋ฅ (4) | 2023.05.23 |
[error] <input>์ value์์ฑ์ด ๊ณ ์ ๊ฐ์ด ์๋๋ผ ๋๋ ์๋ฌ (0) | 2023.05.23 |