Skip to content

Server side render #15

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

Closed

Conversation

StefanoPastore
Copy link

Copy link
Member

@mjackson mjackson left a comment

Choose a reason for hiding this comment

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

I was thinking of something much more lightweight, where we get our initial matches state from the defaultMatches prop (for the initial render) and then update the state again with the media query state in componentDidMount.

@@ -1,2 +1,3 @@
lib
umd
node_modules
Copy link
Member

Choose a reason for hiding this comment

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

Please don't make changes to .gitignore. Thanks :)

const { matches } = this.state

if (defaultMatches && this.firstRender) return this.universalRender(query, children, render)
Copy link
Member

@mjackson mjackson Sep 28, 2016

Choose a reason for hiding this comment

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

In general, this approach feels too heavy for this library. We shouldn't be rendering a <style> tag when rendering on the server.

Copy link
Author

Choose a reason for hiding this comment

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

I get it, but if the rendering is universal then the <style>tag on the server becomes meaningful as a counterpart of the client tag. Also, this is needed for crawlers which expect the markup to be the same on both sides.

Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry, but this PR is just doing way too much. There must be an easier way to achieve what you're after.

Copy link
Author

Choose a reason for hiding this comment

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

Without <style> tag it isn't possibile, but if you want I can change universalRender method as well:

universalRender(){
  return MatchElement
}

For fix warning until we find a better solution.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Well, we can't include a <style> tag in our output. That's taking on too much responsibility. I'm sorry, but if you'd like to take that route you'll have to do it in a separate library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants