20. But I don’t want
my Javascript to be
synchronous!!!
21. Differences
• Browser components communicate with
Stores via Actions. (asynchronous)
• Server components call the Store directly
within a static method. (synchronous)
22. Server
• Render the “route” or view
• Pre-Fetch the data
• Create the HTML as a String
• Store the data where it can be accessed by the
client application.
• Return the response
23.
24. Server Side Render
• Determine what routes/components are active
• Determine what data is needed
• Get the data
• Render the HTML
27. • The router’s run() method is called with a routes
configuration and the current location.
28. • Routes configuration matches a path to a
component in your application.
• When a path is active, the router stores a reference
to all of the active components in its state.
29. • Notice we fetch the data (resolve all promises) and
THEN call the callback with:
• Null (no error)
• The rendered HTML as a String
• The merged data object from the fetches
30.
31. Static Blocks
• The statics object allows you to define static
methods that can be called on the component
class.
• Can be run before any component instances are
created.
35. • Notice we fetch the data (resolve all promises) and
THEN call the callback with:
• Null (no error)
• The rendered html as a String
• The merged data object from the fetches
36. Now the app has been
rendered and the initial
state data has been
fetched.
Hapi Index Route
46. Browser
• Bootstrap the application normally.
• Determine which routes/components are active
• Use the ‘seeded’ data instead of making API
calls during bootstrap process.
• When bootstrap is complete, app behaves as a
normal SPA.
56. You’re Missing the Point of Server-Side Rendered JS - Tom Dale
react-router-mega-demo
Universal Javascript - Michael Jackson
check these out
Ryan Florence’s React Conf Talk
Axios - Matt Zabriske