Upload
bruce-coddington
View
67
Download
3
Embed Size (px)
Citation preview
React
• Javascript library for building user interfaces
• Simple components using JSX
• Can be rendered on the server (more to come)
FLUX
• Unidirectional Data Flow
• Stores - ActionCreators - Dispatcher -Components
• Event Based Architecture
Differences
• Browser components communicate with Stores via Actions. (asynchronous)
• Server components call the Store directly within a static method. (synchronous)
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
Server Side Render
• Determine what routes/components are active
• Determine what data is needed
• Get the data
• Render the HTML
• 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.
• 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
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.
• 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
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.
Me
• @brucecoddington
• https://github.com/brucecoddington
• blue moon ghetto on Spotify
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