ZINC-FYP-2022-23 / console

ZINC UI for teaching assistants
1 stars 0 forks source link

fix: unfinished set-up of Mantine in Next.js #27

Closed AnsonH closed 1 year ago

AnsonH commented 1 year ago

Problem

When running yarn start after commit 5acd6b88, the Mantine stepper is looking weird in initial rendering:

https://user-images.githubusercontent.com/57580593/201523672-45daf403-7379-44bc-af32-5bf38e3d81ad.mp4

Upon closer investigation, Mantine stepper's CSS styles are not present in server side rendered bundle: image

Solution

According to the Mantine documentation, extra set-up is required for Mantine to work in Next.js properly. The set-up requires:

  1. Install @mantine/next
  2. Set up pages/_document.tsx and call Mantine's createGetInitialProps()
  3. Adding <MantineProvider /> to pages_app.tsx

createGetInitialProps() in Step 2 will make sure server side rendering works properly. Since Mantine uses Emotion under the hood for styling, it's possible that omitting this step will cause the above problem