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

Adds isomorphic/server-side React application-shell rendering #35

Merged
merged 13 commits into from
May 18, 2016

Conversation

addyosmani
Copy link
Collaborator

Demo URL: https://react-hn.appspot.com

tl;dr: we can now server-side render the UI, which also enables it to be visible with or without JavaScript enabled

This set of changes formalises the work done in #27 (huge thanks to @jackfranklin and @psimyn) for helping us get it started. The end product can now be trivially deployed to Google App Engine.

@jackfranklin: some of the specific changes I added to your branch were bringing back SSR-friendly hostname parsing, the componentDidMount fix, slightly tighter equality checks and updates to the build pipeline which enable us to deploy to GAE.

cc @insin @NekR

addyosmani added 9 commits May 7, 2016 18:56
This is necessary for a successful deploy to either Heroku or Google
App Engine given we now need all dependencies defined upfront. I’m also
enforcing Node 6.x as earlier versions now timeout thanks to phantomjs.
Introduces `deploy`, localises a lot of the current binaries so that
they don’t require global installs (and work fine on Heroku and
AppEngine). `serve` now gives you the old `start` behaviour and `start`
now just runs the node server that we default to.
@NekR
Copy link
Collaborator

NekR commented May 8, 2016

I am not really React-guy, but if no one will be able to review it, then I'll do review.

@addyosmani
Copy link
Collaborator Author

Thanks! Any help at all with reviews would be 💕

@jackfranklin
Copy link

Awesome - I'll take a look through quickly if that's useful :)

@addyosmani
Copy link
Collaborator Author

@jackfranklin That would be super useful :) @insin would you like for us to wait on your final call after other reviews are done before merging this in if we get go aheads?

@@ -35,7 +35,7 @@ var Stories = React.createClass({
}
},

componentWillMount() {
componentDidMount() {

Choose a reason for hiding this comment

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

more out of interest, but why is this required? Is this what gets around that weird React error I was getting?

Copy link
Owner

Choose a reason for hiding this comment

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

componentDidMount() only gets called on the client

Choose a reason for hiding this comment

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

Ah, of course.

@jackfranklin
Copy link

Looks great!

@@ -0,0 +1,5 @@
runtime: nodejs
Copy link
Owner

Choose a reason for hiding this comment

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

Does this come with any predefined environment variables?

If not, setting NODE_ENV to production will make Express cache the view template

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@insin
Copy link
Owner

insin commented May 11, 2016

You could use something like this <Title/> (other implementations are available) component for isomorphic title handling, but that's pretty minor and easy to add after this PR.

"lint:fix": "eslint --fix .",
"start": "nwb serve",
"precache": "sw-precache --root=public --config=sw-precache-config.json"
"build": "npm run lint && cp node_modules/sw-toolbox/sw-toolbox.js public/sw-toolbox.js && ./node_modules/nwb/lib/bin/nwb.js build && npm run precache",

Choose a reason for hiding this comment

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

can replace ./node_modules/nwb/lib/bin/nwb.js with ./node_modules/.bin/nwb

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. Will update.

@addyosmani addyosmani mentioned this pull request May 17, 2016
@addyosmani
Copy link
Collaborator Author

@insin @tracker1 Attempted to address feedback. PTAL if you get a chance :)

@insin
Copy link
Owner

insin commented May 18, 2016

LGTM!

@addyosmani addyosmani merged commit b2eefd2 into master May 18, 2016
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.

5 participants