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: OakModal blowing up when doing SSR #202

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

carlmw
Copy link
Contributor

@carlmw carlmw commented Jun 18, 2024

document.body isn't available during SSR, so this would blow up.

This commit adds an awful useEffect which flips an isMounted boolean which we can use to determine if we're rendering on the client while avoiding a server->client markup mismatch warning. groan

How to review this PR

  • Check component hierarchy is followed correctly
  • Check the design Heuristics have been followed
  • Check naming conventions have been applied
  • Check for these gotchyas:
    • Missing exports for Oak components
    • Accidental export of Internal components
    • Snapshots of unexpected components have been modified
    • Circular dependencies
    • Code duplication (via not using base components)
    • Non-functional storybook for this or related components
    • Sensitve files changed eg. atoms, or style tokens
    • Relative imports
    • Default exports

https://deploy-preview-202--lively-meringue-8ebd43.netlify.app/?path=/docs/components-molecules-oakmodal--docs

Testing instructions

This should behave as before in Storybook where the modal is always rendered client-side. The only way to test this fix is to use it with SSR (which i've done in OWA to verify).

`document.body` isn't available during SSR, so this would blow up.

This commit adds a awful `useEffect` which flips an `isMounted` boolean
which we can use to determine if we're rendering on the client while
avoiding a server->client markup mismatch warning. *groan*
Copy link

netlify bot commented Jun 18, 2024

Deploy Preview for lively-meringue-8ebd43 ready!

Name Link
🔨 Latest commit cb51ee2
🔍 Latest deploy log https://app.netlify.com/sites/lively-meringue-8ebd43/deploys/6671abd8bb42af00080b6723
😎 Deploy Preview https://deploy-preview-202--lively-meringue-8ebd43.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@carlmw carlmw requested review from simonrose121 and mantagen June 18, 2024 15:57
Copy link
Contributor

@simonrose121 simonrose121 left a comment

Choose a reason for hiding this comment

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

LGTM!

This is pretty how much Next's example handles the same issue: https://github.com/vercel/next.js/tree/canary/examples/with-portals

@carlmw
Copy link
Contributor Author

carlmw commented Jun 19, 2024

LGTM!

This is pretty how much Next's example handles the same issue: https://github.com/vercel/next.js/tree/canary/examples/with-portals

that's where my Googling led me too 😆

@carlmw carlmw merged commit 869515a into main Jun 19, 2024
5 checks passed
@carlmw carlmw deleted the fix-oak-modal-blowing-up-in-ssr branch June 19, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants