-
Notifications
You must be signed in to change notification settings - Fork 116
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
Server side render #15
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
This reverts commit 4c50e85.
See this comment on issue #13