Inflearn brand logo image

Inflearn Community Q&A

tomas30551515's profile image
tomas30551515

asked

[Renewal] Creating NodeBird SNS with React

Q&A before distribution

swr, serversiderendering

Written on

·

364

0

혹시 이제 swr 에서 getServerSideProps 지원 안하나요? 업데이트된 링크 가보니 getStaticProps 예제만 있네용..

https://swr.vercel.app/docs/with-nextjs

reduxnodejsexpressreactNext.js

Answer 1

0

zerocho님의 프로필 이미지
zerocho
Instructor

저기서처럼 fallback에 넣으시면 됩니다.

tomas30551515님의 프로필 이미지
tomas30551515
Questioner

아... swr은 글로벌적으로는 ssr 이 안되네요..

<SWRConfig vlaue={{ fallback }}>ssr을 원하는 컴포넌트</SWRConfig>

이렇게 해야만 그 컴포넌트에서 ssr 이 되는거니 ..

fallback 을 글로벌적으로 전달 하게 하는 방법은 없는 거죠?..

만약 ssr을 원하는 컴포넌트가 AppLayout 에 있는 Header 컴포넌트면 SWRConfig 태그를 Header 컴포넌트에 씌워야 하는 걸까요?...

zerocho님의 프로필 이미지
zerocho
Instructor

일단 Next.js는 페이지 단위입니다. 모든 페이지에 걸쳐 ssr되게는 힘듭니다. 모든 페이지를 SWRConfig로 감싸면 비슷한 효과는 되겠습니다. AppLayout도 pages 폴더 안에서 불러와야 Header가 ssr될 것 같습니다.

tomas30551515님의 프로필 이미지
tomas30551515
Questioner

아 그렇군요.. swr 속성으로 fallback을 넘김넘김 하는게 좀 아쉬워 RTK-query로 결국 적용하였습니다.. 감사합니다!

tomas30551515's profile image
tomas30551515

asked

Ask a question