From MVC to React @ericclemmons
History How this all started 2010 Joined CMN.com 2011 Grew team & developed prototype. 2011 Prototype reached peak success.
Explosive growth & optimization. 2012 Threw away the prototype. 2015
A/B/x Testing Responsive UI Mobile vs. Desktop assets Performance Biggest impact on revenue.
Dismantling the Monolith From PHP to Node Profit?Business LogicAdmin API UI
Javascript is awesome!
Requirements 01 02 03 04 Rendering on the server is just smart. Isomorphic Conceptually easier to understand how logic works. Simple Technology moves fast enough to justify replacing parts within a year. Modular Server responses, rendering, validation. Fast
The Solution As of 2015 React Facebook
Benefits That match our requirements Active F/OSS developers supporting their tools and React in mediums such as Slack pushing Javascript forward. Community Companies with much larger problem sets are leverage React. Adoption Utilizes a Virtual DOM to only render what has changed. Fast Just the View layer, the rest of the architecture is up to you. Simple Server-side & client-side rendering out of the box. Isomorphic
What does it look like? Simple Example
Allows the author to describe what the UI consists of (e.g. TableGrid, UserProfile, CodeEditor, etc.) rather than how. Components
Usually shown as HTML-like attributes, these are external values explicitly passed down to components by their parent. Properties
Internal properties that changes how a component is rendered (e.g. "on" vs. "off"). State
Advanced, scarcely documented feature that allows deeply-nested components to opt-in to a shared state for data-sharing and communication. Context
From MVC... What we know... Model Domain logic View data Constraints Validation ? Controller Handles request Fetches data Performs logic Renders view Sends response ? View Fast Simple Isomorphic One-way data flow React
How does our current app work? High-level overview User wants to adjust what's in their shopping cart. Cart Page A request is made to our server. Request
The router identifies which route(s) can respond to the request. Router Entry-point receives the request. Front Dispatcher The controller fetches the data it designates useful for the view. Controller
The user interacts with the page (e.g. a form). Interaction Javascript updates the view as the user interacts to save round-trips to the server. Progressive Enhancement The view uses the normalized data from the Controller to present it in a useful manner for the user. View
Data is sent to controller, validated, and prepared for storage. HTTP POST User finalizes edits & submits the form. Submit
Now with Javascript.
How can our Javascript app work? High-level overview User wants to adjust what's in their shopping cart. Cart Page Node Request
Server Router + React Router Router Hapi, Express, Koa, etc. Front Dispatcher Component that handles primarily route layout. Handler
User triggers actions that update props & state. Interaction React re-renders the view accordingly. Progressive Enhancement Deeply-nested components that render the view. Components
Data is validated and sent to an API end- point for storage. AJAX POST User finalizes edits & submits the form. Submit
Example Project https://github.com/ericclemmons/mvc-to-react Let's See Some Code!
Server Hapi + React + ES6
Client & Server Hapi + React + Browserify + ES6
Props Client & Server
State Home
Events Untangling the complexity that is Progressive Enhancement.
The Solution ...that no one understood. Flux Facebook
The Solution ...that makes sense. Flux Facebook
Actions Flummox
Store Flummox
App Flux Flummox
Usage Flummox
Separation of Concerns The value of separation of concerns is simplifying development and maintenance of [components]. When concerns are well-separated, individual sections can be reused, as well as developed and updated independently. “ ”
Complex Container Separation of Concerns
Simple Container Separation of Concerns Releasing soon: ericclemmons/react-resolver
Wrapping Up Deliverables Isomorphic Development Rapid Development Clearer Code Separation of Concerns Performance Thriving Ecosystem
Learning http://facebook.github.io/react/ http://conf.reactjs.com/schedule.html https://www.tildedave.com/2014/11/15/introduction-to-contexts-in-react-js.html https://github.com/ericclemmons/mvc-to-react Getting Started https://github.com/RickWong/react-isomorphic-starterkit https://github.com/rackt/react-router/ Other Environments https://github.com/reactjs/react-rails https://github.com/reactjs/React.NET https://github.com/reactjs/react-python https://github.com/reactjs/react-php-v8js Flux Implementations http://goatslacker.github.io/alt/ https://github.com/acdlite/flummox/ https://facebook.github.io/flux/ http://fluxible.io/ http://martyjs.org/ https://github.com/spoike/refluxjs/ Community http://reactiflux.com/ https://reactiflux.herokuapp.com/ https://join-reactiflux.herokuapp.com/
Thank You! https://github.com/ericclemmons/ https://twitter.com/ericclemmons/

From MVC to React