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

Simplify styled-components example #5631

Merged

Conversation

timneutkens
Copy link
Member

cc @mxstbr @probablyup

- use `enhanceApp` so that styled-components used in _app.js are server rendered
- call parent getInitialProps, fixes vercel#5629
- return `styles`, making the render() method obsolete.
Copy link
Contributor

@mxstbr mxstbr left a comment

Choose a reason for hiding this comment

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

Going to defer to @timneutkens for a review of the Next stuff, but from a s-c perspective this looks fine!

EDIT: I'm a dummy and didn't realize you had changed your avatar. 🤦‍♂️ 🤦‍♂️ 🤦‍♂️ 🤦‍♂️

Shipit!

@timneutkens
Copy link
Member Author

@mxstbr I am @timneutkens 😂 😄

@timneutkens timneutkens merged commit ed2c379 into vercel:canary Nov 8, 2018
@timneutkens timneutkens deleted the fix/styled-components-example branch November 8, 2018 11:43
@jsardev
Copy link

jsardev commented Nov 16, 2018

Nice! @timneutkens What is enhanceApp and why it's not documented anywhere? 😭

@klujanrosas
Copy link
Contributor

klujanrosas commented Nov 21, 2018

@sarneeh It was a change introduced here #4762

Usage before #4762 was:

renderPage(Page => Page)

This applied the enhancer to the Page component.

Now, it also takes an options object(although previous behaviour was kept for backwards compatibility):

renderPage({
  enhanceApp: App => App,
  ehhanceComponent: Component => Component
})

As @timneutkens mentioned here

this enhancer is not documented in the readme and the only use case it was meant to support is styled-components / other css-in-js libs that require the react tree

@jsardev
Copy link

jsardev commented Nov 21, 2018

@klujanrosas Thank you for the explanation! I didn't stumble upon this PR 😄

@timneutkens
Copy link
Member Author

Honestly I think we can document this by now with the approach taken in this PR. The reason I said not to document it was because renderPage would have to be called instead of super.getInitialProps, which is not the case as per this PR 😄

@klujanrosas
Copy link
Contributor

klujanrosas commented Nov 21, 2018

Hey @timneutkens , do you think it should it be documented on the repo's README?
Or on the example itself

I went ahead and gave it a shot in #5723

@timneutkens
Copy link
Member Author

The repo readme

timneutkens pushed a commit that referenced this pull request Dec 10, 2018
…cument.js (#5723)

Per @timneutkens suggestion [here](#5631 (comment)) I went ahead and gave a shot at trying to document `renderPage` usage.

This PR:
- Documents `renderPage` legacy and current usage.
@lock lock bot locked as resolved and limited conversation to collaborators Nov 21, 2019
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.

Global styles not being rendered server side and only occuring client side with flicker
4 participants