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

fix: Fix code block hydration errors #11046

Merged
merged 4 commits into from
Aug 12, 2024
Merged

fix: Fix code block hydration errors #11046

merged 4 commits into from
Aug 12, 2024

Conversation

chargome
Copy link
Member

@chargome chargome commented Aug 9, 2024

  • Remove unused code
  • Stop using @next/mdx
  • Load prismjs dynamically in ApiExamples component

fixes #10574
might fix errors for switching code tabs (#10719)

Copy link

vercel bot commented Aug 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
changelog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 9, 2024 5:11pm
develop-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 9, 2024 5:11pm
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 9, 2024 5:11pm

Copy link

codecov bot commented Aug 9, 2024

Bundle Report

Changes will decrease total bundle size by 16.29kB ⬇️

Bundle name Size Change
sentry-docs-server 8.24MB 19.23kB ⬇️
sentry-docs-edge-server 253.05kB 3 bytes ⬇️
sentry-docs-client 6.25MB 2.94kB ⬆️

Copy link
Member

@lforst lforst left a comment

Choose a reason for hiding this comment

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

Generally, I wouldn't mind if we merged in this state. However, can we leave a few extra comments explaining wtf is going on with the lazy loading stuff?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for removing this. I think I missed this file in the changelog migration.

Comment on lines +61 to +64
__html: JSON.stringify(
api.responses[selectedResponse].content?.schema,
null,
2
Copy link
Member

Choose a reason for hiding this comment

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

Is there any way uncontrolled input can land here?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point, but no, this is just the filtered response of our openAPI call

@@ -25,29 +29,39 @@ function Example({api, selectedTabView, selectedResponse}: ExampleProps) {
exampleJson = api.responses[selectedResponse].content?.example;
}

// load prism dynamically for these codeblocks,
// otherwise the highlighting applies globally
useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Will this cause layout shift or flashing because it paints some time after the initial page load? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but it did that before as well. We could also think about not dynamically loading prismjs at all and instead use what we already have (rehypePrismPlus). This would streamline the style of the API JSON examples with our other codeblocks. This would require more work though, we can do it in another pr if needed.

next.config.js Show resolved Hide resolved
app/layout.tsx Show resolved Hide resolved
@lforst
Copy link
Member

lforst commented Aug 12, 2024

Feel free to merge!

@chargome chargome merged commit 25def56 into master Aug 12, 2024
11 checks passed
@chargome chargome deleted the cg/fix-hydration-err branch August 12, 2024 09:00
@chargome chargome mentioned this pull request Aug 13, 2024
2 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hydration errors on dev server
2 participants