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

Advanced: SSR styles encapsulated in a Higher-Order Component #9

Draft
wants to merge 1 commit into
base: fix/ssr-styles
Choose a base branch
from

Conversation

lucasconstantino
Copy link
Contributor

@lucasconstantino lucasconstantino commented Jun 13, 2022

⚠️ Warning

The changes contained in this PR are considered advanced, and won't be part of the final application. We'll leave it here as a reference and for learning purposes.


This PR intends to showcase two things:

  1. Real world use case of a HOC (Higher-Order Component)
  2. How to use HOCs to decouple concerns

The idea here is we abstract away the whole styles SSR logic – which was copied from Next.js' official styled-components example – out of the _document.tsx page. The intention is to isolate the complexity of this styles SSR process, and make our custom Document as simple as possible, with only application concerns and not low-level SSR concerns.

Besides that, having the styles SSR encapsulated allows the Document to embark other eventual getInitialProps needs that might become necessary, without us having to mingle the complexity of multiple different concerns.

@vercel
Copy link

vercel bot commented Jun 13, 2022

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

Name Status Preview Updated
frontend-academy-2022 ✅ Ready (Inspect) Visit Preview Jun 13, 2022 at 1:47PM (UTC)

@lucasconstantino lucasconstantino changed the base branch from main to fix/ssr-styles June 13, 2022 13:52
@lucasconstantino lucasconstantino marked this pull request as draft June 13, 2022 13:53
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.

None yet

1 participant