hmu332233 / tips

https://tips.minung.dev
1 stars 0 forks source link

nextjs #38

Open hmu332233 opened 2 years ago

hmu332233 commented 2 years ago

keyword suspense,ssr

hmu332233 commented 2 years ago

next/dynamic을 사용해서 lazy 로딩시 fallback 처리 방법

// pre rendering 단계에서 Loading 컴포넌트 표시됨
const Component = dynamic(() => import('Component'), {
  loading: () => (<Loading />),
  ssr: false,
});

<Component />
// pre rendering 단계에서 Component 컴포넌트 표시됨
const Component = dynamic(() => import('Component'), {
  suspense: true
});

<Suspense fallback={<Loading />}>
  <Component />
</Suspense>