Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #48483 #49694

Closed
Closed

Conversation

SamarthBagga
Copy link

@SamarthBagga SamarthBagga commented May 12, 2023

What

Fixed issue #48483- There was a flash of unstyled design in the with-ant-design example in the repo.

How

Created a _document.tsx file with a head component with a link to the ant design stylesheet.

Why

To prevent the flash of unstyled content in my Next.js application, I added a custom Document component. In this component, I included a link to the Ant Design CSS stylesheet within the section. This ensures that the styles from Ant Design are loaded and applied to the page during server-side rendering (SSR). By extending the default Document component, I was able to customize the HTML structure of the page and include the necessary styles, providing a seamless and styled user experience.

Fixed issue vercel#48483 by adding a Head tag with the a link to the ant design css. I did this because the issue was related to server-side rendering, where the HTML generated on the server did not include the necessary CSS styles for the Ant Design components, leading to a flash of unstyled components on page load. By adding the <Head> tag and including the necessary CSS styles, we were able to ensure that the CSS is included in the HTML generated on the server, thereby avoiding the flash of unstyled components.
@SamarthBagga SamarthBagga requested review from a team, leerob and steven-tey as code owners May 12, 2023 08:22
@ijjk ijjk added the examples Issue/PR related to examples label May 12, 2023
@@ -26,6 +28,10 @@ export default function Home() {
}

return (
<div>
<Head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/antd/dist/antd.css" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the heads up ! I'll make the necessary changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @B2o5T
I have made the changes according to your suggestion.

To prevent the flash of unstyled content in my Next.js application, I added a custom Document component. In this component, I included a link to the Ant Design CSS stylesheet within the <Head> section. This ensures that the styles from Ant Design are loaded and applied to the page during server-side rendering (SSR). By extending the default Document component, I was able to customize the HTML structure of the page and include the necessary styles, providing a seamless and styled user experience
@SamarthBagga SamarthBagga changed the title updated-index.tsx-antDesign Fixed #48483 May 16, 2023
@SamarthBagga
Copy link
Author

Hi @B2o5T could you review my pull request?

@dimaMachina
Copy link

Hi, I am not part of Next.js team, ping them instead

@SamarthBagga
Copy link
Author

@leerob @steven-tey Could you review my pull request?

@leerob
Copy link
Member

leerob commented Jun 15, 2023

Closing this out, as we'd like to move the example to use the App Router instead 🙏

@leerob leerob closed this Jun 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue/PR related to examples locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants