SlideShare a Scribd company logo
Rami Sayar - @ramisayar
Senior Technical Evangelist
Microsoft Canada
@RAMISAYAR
@RAMISAYAR
@RAMISAYAR
@RAMISAYAR
• Introduction to React & the Environment
• Useful React Libraries
• What is Flux & Redux
• Useful Redux Libraries
• What is Relay (and other Reactive Databases/APIs)
• Useful React Dev Tools
Assumption: Beginner React Developer
@RAMISAYAR
@RAMISAYAR
• React is a UI
*library* developed
at Facebook.
• Lets you create
interactive, stateful &
reusable UI
components.
@RAMISAYAR
• React adds this weird thing to your HTML called JSX.
• Let’s you write HTML-ish tags in JavaScript to simplify creating
components.
var HelloWorldComponent = React.createClass({
render: function(){
return ( <h1>Hello, world!</h1> );
}
});
@RAMISAYAR
React.createElement('h1', null, 'Hello, world!')
• Added attributes are called props and can be used to render
dynamic data.
var HelloNameComponent = React.createClass({
render: function(){
return ( <h1>Hello, {this.props.name}!</h1> );
}
});
ReactDOM.render(<HelloNameComponent name="Rami"
/>, document.getElementById('app'));
@RAMISAYAR
• Render method is the only required spec for creating a
component.
• React has lifecycle methods:
• componentWillMount – Invoked once, on both client & server before
rendering occurs.
• componentDidMount – Invoked once, only on the client, after
rendering occurs.
• shouldComponentUpdate – Return value determines whether
component should update.
• componentWillUnmount – Invoked prior to unmounting component.
@RAMISAYAR
@RAMISAYAR
• Every component has a state object and a props object.
• Functions & Objects:
• getInitialState – Return value is the initial value for state.
• setState – Sets the state and triggers UI updates.
• getDefaultProps – Sets fallback props values if props aren’t supplied.
@RAMISAYAR
• Every component has a
state object and a props
object.
• Data flows unidirectionally
via the state and props
objects.
@RAMISAYAR
• React can be used on both the client and server side.
• Uses a Virtual DOM to selectively render subtrees of
components on state change.
• To assign CSS classes you have to use className.
• You can use ES6 Classes instead of the createClass function.
@RAMISAYAR
@RAMISAYAR
Create React apps with no build configuration.
npm install -g create-react-app
create-react-app my-app
cd my-app/
npm start
@RAMISAYAR
• Webpack
• Babel with ES6 extensions (JSX, object spread, class properties)
• Autoprefixer
• ESLint
• Jest
@RAMISAYAR
@RAMISAYAR
$ npm install --save-dev babel-cli babel-preset-
latest babel-preset-react
Adds ES2015-7 language features to JavaScript.
• Websites are complex and there are multiple styles for
bundling JavaScript code (CommonJS, AMD, ES6, etc).
• Webpack takes modules with dependencies and generates
static assets.
@RAMISAYAR
@RAMISAYAR
• Webpack also comes with a few interesting features:
• Hot Module Replacement
• Development Server
• Optimization
• Caching
@RAMISAYAR
• React Router keeps your UI in sync with the URL.
• Features like lazy code loading, dynamic route matching, and
location transition handling are built in.
render((
<Router history={browserHistory}>
<Route path="/" component={App}>
<Route path="about" component={About}/>
<Route path="*" component={NoMatch}/>
</Route>
</Router>
), document.body)
@RAMISAYAR
• react-bootstrap wraps Bootstrap into React Components.
var buttonGroupInstance = (
<ButtonGroup>
<DropdownButton bsStyle="success" title="Dropdown">
<MenuItem key="1">Dropdown</MenuItem>
</DropdownButton>
<Button bsStyle="info">Hello</Button>
</ButtonGroup>
);
@RAMISAYAR
“Foundation Apps is a new framework for building web
apps. It has awesome new features like flexbox based
grid, motion-ui, and several core components for
building web apps.” https://github.com/akiran/react-
foundation-apps
@RAMISAYAR
• Elemental UI is a UI Toolkit for React.js Websites and Apps
@RAMISAYAR
“This is a collection of some of the most
reusable React components built at Khan Academy. […]
We're trying to make it just as easy to jumpstart React
applications with a well-tested, thoughtful, and beautiful
library of components.” http://khan.github.io/react-
components/
@RAMISAYAR
Unresolved topic but check out: FormidableLabs/radium
@RAMISAYAR
@RAMISAYAR
@RAMISAYAR
• React makes it easy to build reuseable and composable components (a.k.a. Views).
• React discourages bidirectional communication for the above to be true.
• This conflicts with MVC where Controller-View communication is bidirectional.
• Flux is the architecture that Facebook uses for building client-
side web apps.
• Flux doesn’t follow MVC in favor of a unidirectional data flow.
• Flux architecture is composed of four major parts: Dispatchers,
Stores, Views and Actions.
@RAMISAYAR
@RAMISAYAR
• Dispatchers are the central hubs that manage data flow (actions).
• Essentially registry of callbacks into Stores.
• When Actions passed into the central Dispatcher, they are redistributed to
the Stores.
• Dispatchers manage dependencies between Stores.
• Stores contain the application state and logic (sort of like the Model
in MVC)
• Stores register themselves with the Dispatcher to receive Actions via a
callback.
• Actions describe state changes in the Store.
• Stores broadcast an event saying they have changed so Views can update.
@RAMISAYAR
• Views are the React Components.
• React Components are composable and are typically nested in a tree
hierarchy.
• A special “App View” behaves like a controller-view and provides glue
code to propagate states down the chain.
• Events cause Views to request the State from a Store to setState() so
that render() will be executed.
• Actions describe a change and include a payload of data.
@RAMISAYAR
• Several Different Implementations of Flux:
• Flux by Facebook
• Redux by Dan Abramov
• Alt by Josh Perez
• Reflux by Mikael Brassman
• Fluxxor by Michelle Tilley
@RAMISAYAR
• The whole state of your app is stored in an object tree inside a
single store.
• The only way to change the state tree is to emit an action, an
object describing what happened.
• To specify how the actions transform the state tree, you write
pure reducers.
Source: https://github.com/reactjs/redux
@RAMISAYAR
• Flux by Facebook
@RAMISAYAR
Use react-router-redux to sync routing state with your Redux stores.
Awesome Redux List
@RAMISAYAR
• reselect is a selector library for Redux
• Compute derived data => reduces size of the state object in
Redux
• Efficient way to handle computing derived data => don’t
recompute state if arguments didn’t change.
• Selectors are composable.
@RAMISAYAR
• Immutable.js provides immutable collections and data
structures.
• Immutable: Once created, cannot be altered at another point.
• Persistent: Both original and mutated collections are valid.
• Structural Sharing: New collections are created using the same
structure as the original collection to reduce copying and achieve
space/performance efficiencies.
• List, Stack, Map, OrderedMap, Set, OrderedSet and Record.
• Use in combination with Redux ->
https://github.com/gajus/redux-immutable
@RAMISAYAR
• Flux Standard Action is a human-friendly standard for Flux
action objects.
• Action objects must be plain JavaScript objects and have a type
property.
• They can also have an error, payload and a meta property.
• Use with:
• redux-actions - a set of helpers for creating and handling FSA actions
in Redux.
• redux-promise - Redux promise middleware that supports FSA actions.
@RAMISAYAR
• Redux Thunk middleware allows you to write action creators
that return a function instead of an action.
• Thunk can be used to delay the dispatch of an action, or to
dispatch only if a certain condition is met.
• Helps you to have asynchronicity in your action creators e.g. so
you can perform API calls, etc.
@RAMISAYAR
@RAMISAYAR
• Relay is a JavaScript Framework for Building Data-Driven React
Applications by Facebook.
• Declarative: Use GraphQL to declare data requirements and let Relay
figure out how and when to fetch data.
• Colocation: Queries live next to views. Relay aggregates queries for
network efficiencies.
• Mutations: Relay lets you mutate data on the client and server using
GraphQL.
@RAMISAYAR
• Falcor is a JavaScript library for efficient data fetching by Netflix.
• One Model Everywhere: Represent remote data as a JSON graph. Treat
data the same everywhere (in memory, client, network, etc).
• Data is the API: JavaScript-like path syntax to access data. Retrieve data
using JavaScript operations like get, set, and call.
• Bind to the Cloud: Falcor automatically traverses references in your
graph and makes requests as needed. Falcor transparently handles
and aggregates requests for network efficiencies.
@RAMISAYAR
• React Resolver lets you define data requirements per-
component and will handle the nested, async rendering on both
the server & client for you.
@resolve("user", function(props) {
return http.get('/api/users/${props.params.userId}');
})
class UserProfile extends React.Component {
render() { ...
@RAMISAYAR
@RAMISAYAR
• Adds a new tab titled "React" in your Chrome DevTools.
• Shows list of the React Component hierarchy.
@RAMISAYAR
• Lets you inspect every state
and action payload.
• Lets you go back in time by
“cancelling” actions.
• If you change the reducer
code, each “staged” action will
be re-evaluated.
• If the reducers throw, you will
see during which action this
happened, and what the
error was.
@RAMISAYAR
• babel-plugin-react-transform wraps React components with
arbitrary transforms. In other words, it allows you to instrument
React components in any way—limited only by your
imagination.
• react-transform-hmr - enables hot reloading using HMR API
• react-transform-catch-errors - catches errors inside render()
• react-transform-debug-inspector - renders an inline prop inspector
• react-transform-render-visualizer - highlight components when
updated
@RAMISAYAR
@RAMISAYAR
• insin/nwb - Create React apps, components, libraries and other
npm modules for use on the web with no configuration (until
you need it).
• mozilla/neo - Neo bakes in the best-of-the-bunch
configurations and setup to make developing React-based sites
quicker and easier.
• NYTimes/kyt - Every sizable JavaScript web app needs a
common foundation: a setup to build, run, test and lint your
code. kyt is a toolkit that encapsulates and manages the
configuration for web apps.
@RAMISAYAR
• MERN is the easiest way to build universal JavaScript apps
using React and Redux.
• MERN Starter - A powerful boilerplate project that gives you a
solid head start on building universal React apps.
• MERN cli - A command line utility that enables you to work with
your MERN based projects easily by providing powerful code
generation and scaffolding abilities.
@RAMISAYAR
• React Starter Kit is an opinionated boilerplate for web
development built on top of Facebook's React library, Node.js /
Express server and Flux architecture.
• Containing modern web development tools such
as Webpack, Babel and Browser Sync.
@RAMISAYAR
• A static website starter kit powered by React.js and Webpack.
✓ Generates static .html pages from React components
✓ Generates routes based on the list of files in the /pages folder
✓ Next generation JavaScript with Babel
✓ Sass syntax for CSS via postCSS and precss
✓ Development web server with BrowserSync and React Transform
✓ Bundling and optimization with Webpack
✓ Yeoman generator (generator-react-static)
@RAMISAYAR
@RAMISAYAR
• React Native by Facebook enables you to build on native
platforms using JavaScript and React.
• React Native focuses on developer efficiency — learn once,
write anywhere.
• Supports iOS and Android.
@RAMISAYAR
• Use standard platform components such as UITabBar on iOS
and Drawer on Android.
• Apps have a consistent look and feel with the rest of the
platform ecosystem and have native performance.
• Operations between JavaScript and the native platform are
performed asynchronously.
• Communication is fully serializable, allows you to debug the
JavaScript while running the complete app, either in the
simulator or on a physical device.
@RAMISAYAR
@RAMISAYAR
• Introduced React & the Ecosystem
• What is Flux Architecture
• Flux, Redux, Alt.js, etc.
• Introduced React Libraries and UI Component Libraries
• Introduced Relay, Falcor & React Resolver
• Introduced React Native
• Useful React Dev Tools
@RAMISAYAR
@RAMISAYAR
tw: @ramisayar | gh: @sayar
@RAMISAYAR
• https://www.toptal.com/react/navigating-the-react-ecosystem
• https://github.com/enaqx/awesome-react
• https://github.com/facebook/react/wiki/Complementary-Tools
• http://slides.com/cguedes/a-tour-on-react-ecosystem
@RAMISAYAR
©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the
U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft
must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after
the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related Content

What's hot (20)

PDF
PLAT-8 Spring Web Scripts and Spring Surf
Alfresco Software
 
PPTX
Agile sites2
Michele Sciabarrà
 
PDF
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
PDF
Frameworks and webcomponents
Filip Bruun Bech-Larsen
 
PPTX
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
PDF
Building modular applications with the Java Platform Module System and Layrry
Andres Almiray
 
PPTX
Agile sites @ telmore
Michele Sciabarrà
 
PPT
Intro to Ruby on Rails
Mark Menard
 
KEY
SOA on Rails
Avi Flombaum
 
PDF
Laravel Introduction
Ahmad Shah Hafizan Hamidin
 
PPT
Java EE revisits design patterns
Alex Theedom
 
PPTX
API Development with Laravel
Michael Peacock
 
PDF
PLAT-7 Spring Web Scripts and Spring Surf
Alfresco Software
 
PDF
Padrino - the Godfather of Sinatra
Stoyan Zhekov
 
PPTX
Hybrid Mobile Development with Apache Cordova and
Ryan Cuprak
 
PPTX
2011 NetUG HH: ASP.NET MVC & HTML 5
Daniel Fisher
 
PDF
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
PDF
Adobe AEM CQ5 - Developer Introduction
Yash Mody
 
PDF
Fluxible
Taylor Lovett
 
PPTX
No Container: a Modern Java Stack with Bootique
Andrus Adamchik
 
PLAT-8 Spring Web Scripts and Spring Surf
Alfresco Software
 
Agile sites2
Michele Sciabarrà
 
Webcomponents are your frameworks best friend
Filip Bruun Bech-Larsen
 
Frameworks and webcomponents
Filip Bruun Bech-Larsen
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
Building modular applications with the Java Platform Module System and Layrry
Andres Almiray
 
Agile sites @ telmore
Michele Sciabarrà
 
Intro to Ruby on Rails
Mark Menard
 
SOA on Rails
Avi Flombaum
 
Laravel Introduction
Ahmad Shah Hafizan Hamidin
 
Java EE revisits design patterns
Alex Theedom
 
API Development with Laravel
Michael Peacock
 
PLAT-7 Spring Web Scripts and Spring Surf
Alfresco Software
 
Padrino - the Godfather of Sinatra
Stoyan Zhekov
 
Hybrid Mobile Development with Apache Cordova and
Ryan Cuprak
 
2011 NetUG HH: ASP.NET MVC & HTML 5
Daniel Fisher
 
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
Adobe AEM CQ5 - Developer Introduction
Yash Mody
 
Fluxible
Taylor Lovett
 
No Container: a Modern Java Stack with Bootique
Andrus Adamchik
 

Viewers also liked (8)

PDF
FITC - Here Be Dragons: Advanced JavaScript Debugging
Rami Sayar
 
PDF
Corso su ReactJS
LinkMe Srl
 
PDF
Navigating the React Ecosystem
Federico Bond
 
PDF
A React Journey
LinkMe Srl
 
PDF
Introduction to React Native
Rami Sayar
 
PDF
React Ecosystem
Craig Jolicoeur
 
PDF
Building React Applications with Redux
FITC
 
PPTX
React + Redux Introduction
Nikolaus Graf
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
Rami Sayar
 
Corso su ReactJS
LinkMe Srl
 
Navigating the React Ecosystem
Federico Bond
 
A React Journey
LinkMe Srl
 
Introduction to React Native
Rami Sayar
 
React Ecosystem
Craig Jolicoeur
 
Building React Applications with Redux
FITC
 
React + Redux Introduction
Nikolaus Graf
 
Ad

Similar to An Intense Overview of the React Ecosystem (20)

PDF
An Overview of the React Ecosystem
FITC
 
PPTX
React.js at Cortex
Geoff Harcourt
 
PDF
The Road To Redux
Jeffrey Sanchez
 
PPTX
React + Flux = Joy
John Need
 
PPSX
React introduction
Kashyap Parmar
 
PPTX
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
PPTX
ReactJS
Ram Murat Sharma
 
PDF
FRONTEND DEVELOPMENT WITH REACT.JS
IRJET Journal
 
PDF
Tech Talk on ReactJS
Atlogys Technical Consulting
 
PPTX
ReactJS
Fatih Şimşek
 
PDF
React & Flux Workshop
Christian Lilley
 
PDF
React Tech Salon
Chenguang ZHANG
 
PDF
theory-slides-vueh3urh4ur4ur4r44oirj4riu4ri
paridhiagarwal129
 
PPTX
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
PPTX
React. Flux. Redux. by Andrey Kolodnitskiy
Valeriia Maliarenko
 
PPTX
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
PPTX
ReactJS Code Impact
Raymond McDermott
 
PDF
React & Redux
Federico Bond
 
PPTX
ReactJS - Re-rendering pages in the age of the mutable DOM
Marc Cyr
 
An Overview of the React Ecosystem
FITC
 
React.js at Cortex
Geoff Harcourt
 
The Road To Redux
Jeffrey Sanchez
 
React + Flux = Joy
John Need
 
React introduction
Kashyap Parmar
 
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
FRONTEND DEVELOPMENT WITH REACT.JS
IRJET Journal
 
Tech Talk on ReactJS
Atlogys Technical Consulting
 
React & Flux Workshop
Christian Lilley
 
React Tech Salon
Chenguang ZHANG
 
theory-slides-vueh3urh4ur4ur4r44oirj4riu4ri
paridhiagarwal129
 
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
React. Flux. Redux. by Andrey Kolodnitskiy
Valeriia Maliarenko
 
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
ReactJS Code Impact
Raymond McDermott
 
React & Redux
Federico Bond
 
ReactJS - Re-rendering pages in the age of the mutable DOM
Marc Cyr
 
Ad

More from Rami Sayar (8)

PDF
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Rami Sayar
 
PDF
Here Be Dragons - Debugging WordPress
Rami Sayar
 
PDF
What's New in ES6 for Web Devs
Rami Sayar
 
PDF
Scalable Django Architecture
Rami Sayar
 
PDF
The State of WebSockets in Django
Rami Sayar
 
PDF
FITC - Bootstrap Unleashed
Rami Sayar
 
PDF
FITC - Node.js 101
Rami Sayar
 
PDF
FITC - Data Visualization in Practice
Rami Sayar
 
Creating Beautiful CSS3 Animations - FITC Amsterdam 2016
Rami Sayar
 
Here Be Dragons - Debugging WordPress
Rami Sayar
 
What's New in ES6 for Web Devs
Rami Sayar
 
Scalable Django Architecture
Rami Sayar
 
The State of WebSockets in Django
Rami Sayar
 
FITC - Bootstrap Unleashed
Rami Sayar
 
FITC - Node.js 101
Rami Sayar
 
FITC - Data Visualization in Practice
Rami Sayar
 

Recently uploaded (20)

PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Digital water marking system project report
Kamal Acharya
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PPTX
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PPT
Testing and final inspection of a solar PV system
MuhammadSanni2
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PPT
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Digital water marking system project report
Kamal Acharya
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
Distribution reservoir and service storage pptx
dhanashree78
 
Testing and final inspection of a solar PV system
MuhammadSanni2
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Design Thinking basics for Engineers.pdf
CMR University
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 

An Intense Overview of the React Ecosystem

  • 1. Rami Sayar - @ramisayar Senior Technical Evangelist Microsoft Canada @RAMISAYAR
  • 5. • Introduction to React & the Environment • Useful React Libraries • What is Flux & Redux • Useful Redux Libraries • What is Relay (and other Reactive Databases/APIs) • Useful React Dev Tools Assumption: Beginner React Developer @RAMISAYAR
  • 7. • React is a UI *library* developed at Facebook. • Lets you create interactive, stateful & reusable UI components. @RAMISAYAR
  • 8. • React adds this weird thing to your HTML called JSX. • Let’s you write HTML-ish tags in JavaScript to simplify creating components. var HelloWorldComponent = React.createClass({ render: function(){ return ( <h1>Hello, world!</h1> ); } }); @RAMISAYAR React.createElement('h1', null, 'Hello, world!')
  • 9. • Added attributes are called props and can be used to render dynamic data. var HelloNameComponent = React.createClass({ render: function(){ return ( <h1>Hello, {this.props.name}!</h1> ); } }); ReactDOM.render(<HelloNameComponent name="Rami" />, document.getElementById('app')); @RAMISAYAR
  • 10. • Render method is the only required spec for creating a component. • React has lifecycle methods: • componentWillMount – Invoked once, on both client & server before rendering occurs. • componentDidMount – Invoked once, only on the client, after rendering occurs. • shouldComponentUpdate – Return value determines whether component should update. • componentWillUnmount – Invoked prior to unmounting component. @RAMISAYAR
  • 12. • Every component has a state object and a props object. • Functions & Objects: • getInitialState – Return value is the initial value for state. • setState – Sets the state and triggers UI updates. • getDefaultProps – Sets fallback props values if props aren’t supplied. @RAMISAYAR
  • 13. • Every component has a state object and a props object. • Data flows unidirectionally via the state and props objects. @RAMISAYAR
  • 14. • React can be used on both the client and server side. • Uses a Virtual DOM to selectively render subtrees of components on state change. • To assign CSS classes you have to use className. • You can use ES6 Classes instead of the createClass function. @RAMISAYAR
  • 16. Create React apps with no build configuration. npm install -g create-react-app create-react-app my-app cd my-app/ npm start @RAMISAYAR
  • 17. • Webpack • Babel with ES6 extensions (JSX, object spread, class properties) • Autoprefixer • ESLint • Jest @RAMISAYAR
  • 18. @RAMISAYAR $ npm install --save-dev babel-cli babel-preset- latest babel-preset-react Adds ES2015-7 language features to JavaScript.
  • 19. • Websites are complex and there are multiple styles for bundling JavaScript code (CommonJS, AMD, ES6, etc). • Webpack takes modules with dependencies and generates static assets. @RAMISAYAR
  • 20. @RAMISAYAR • Webpack also comes with a few interesting features: • Hot Module Replacement • Development Server • Optimization • Caching
  • 22. • React Router keeps your UI in sync with the URL. • Features like lazy code loading, dynamic route matching, and location transition handling are built in. render(( <Router history={browserHistory}> <Route path="/" component={App}> <Route path="about" component={About}/> <Route path="*" component={NoMatch}/> </Route> </Router> ), document.body) @RAMISAYAR
  • 23. • react-bootstrap wraps Bootstrap into React Components. var buttonGroupInstance = ( <ButtonGroup> <DropdownButton bsStyle="success" title="Dropdown"> <MenuItem key="1">Dropdown</MenuItem> </DropdownButton> <Button bsStyle="info">Hello</Button> </ButtonGroup> ); @RAMISAYAR
  • 24. “Foundation Apps is a new framework for building web apps. It has awesome new features like flexbox based grid, motion-ui, and several core components for building web apps.” https://github.com/akiran/react- foundation-apps @RAMISAYAR
  • 25. • Elemental UI is a UI Toolkit for React.js Websites and Apps @RAMISAYAR
  • 26. “This is a collection of some of the most reusable React components built at Khan Academy. […] We're trying to make it just as easy to jumpstart React applications with a well-tested, thoughtful, and beautiful library of components.” http://khan.github.io/react- components/ @RAMISAYAR
  • 27. Unresolved topic but check out: FormidableLabs/radium @RAMISAYAR
  • 29. @RAMISAYAR • React makes it easy to build reuseable and composable components (a.k.a. Views). • React discourages bidirectional communication for the above to be true. • This conflicts with MVC where Controller-View communication is bidirectional.
  • 30. • Flux is the architecture that Facebook uses for building client- side web apps. • Flux doesn’t follow MVC in favor of a unidirectional data flow. • Flux architecture is composed of four major parts: Dispatchers, Stores, Views and Actions. @RAMISAYAR
  • 32. • Dispatchers are the central hubs that manage data flow (actions). • Essentially registry of callbacks into Stores. • When Actions passed into the central Dispatcher, they are redistributed to the Stores. • Dispatchers manage dependencies between Stores. • Stores contain the application state and logic (sort of like the Model in MVC) • Stores register themselves with the Dispatcher to receive Actions via a callback. • Actions describe state changes in the Store. • Stores broadcast an event saying they have changed so Views can update. @RAMISAYAR
  • 33. • Views are the React Components. • React Components are composable and are typically nested in a tree hierarchy. • A special “App View” behaves like a controller-view and provides glue code to propagate states down the chain. • Events cause Views to request the State from a Store to setState() so that render() will be executed. • Actions describe a change and include a payload of data. @RAMISAYAR
  • 34. • Several Different Implementations of Flux: • Flux by Facebook • Redux by Dan Abramov • Alt by Josh Perez • Reflux by Mikael Brassman • Fluxxor by Michelle Tilley @RAMISAYAR
  • 35. • The whole state of your app is stored in an object tree inside a single store. • The only way to change the state tree is to emit an action, an object describing what happened. • To specify how the actions transform the state tree, you write pure reducers. Source: https://github.com/reactjs/redux @RAMISAYAR
  • 36. • Flux by Facebook @RAMISAYAR
  • 37. Use react-router-redux to sync routing state with your Redux stores. Awesome Redux List @RAMISAYAR
  • 38. • reselect is a selector library for Redux • Compute derived data => reduces size of the state object in Redux • Efficient way to handle computing derived data => don’t recompute state if arguments didn’t change. • Selectors are composable. @RAMISAYAR
  • 39. • Immutable.js provides immutable collections and data structures. • Immutable: Once created, cannot be altered at another point. • Persistent: Both original and mutated collections are valid. • Structural Sharing: New collections are created using the same structure as the original collection to reduce copying and achieve space/performance efficiencies. • List, Stack, Map, OrderedMap, Set, OrderedSet and Record. • Use in combination with Redux -> https://github.com/gajus/redux-immutable @RAMISAYAR
  • 40. • Flux Standard Action is a human-friendly standard for Flux action objects. • Action objects must be plain JavaScript objects and have a type property. • They can also have an error, payload and a meta property. • Use with: • redux-actions - a set of helpers for creating and handling FSA actions in Redux. • redux-promise - Redux promise middleware that supports FSA actions. @RAMISAYAR
  • 41. • Redux Thunk middleware allows you to write action creators that return a function instead of an action. • Thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met. • Helps you to have asynchronicity in your action creators e.g. so you can perform API calls, etc. @RAMISAYAR
  • 43. • Relay is a JavaScript Framework for Building Data-Driven React Applications by Facebook. • Declarative: Use GraphQL to declare data requirements and let Relay figure out how and when to fetch data. • Colocation: Queries live next to views. Relay aggregates queries for network efficiencies. • Mutations: Relay lets you mutate data on the client and server using GraphQL. @RAMISAYAR
  • 44. • Falcor is a JavaScript library for efficient data fetching by Netflix. • One Model Everywhere: Represent remote data as a JSON graph. Treat data the same everywhere (in memory, client, network, etc). • Data is the API: JavaScript-like path syntax to access data. Retrieve data using JavaScript operations like get, set, and call. • Bind to the Cloud: Falcor automatically traverses references in your graph and makes requests as needed. Falcor transparently handles and aggregates requests for network efficiencies. @RAMISAYAR
  • 45. • React Resolver lets you define data requirements per- component and will handle the nested, async rendering on both the server & client for you. @resolve("user", function(props) { return http.get('/api/users/${props.params.userId}'); }) class UserProfile extends React.Component { render() { ... @RAMISAYAR
  • 47. • Adds a new tab titled "React" in your Chrome DevTools. • Shows list of the React Component hierarchy. @RAMISAYAR
  • 48. • Lets you inspect every state and action payload. • Lets you go back in time by “cancelling” actions. • If you change the reducer code, each “staged” action will be re-evaluated. • If the reducers throw, you will see during which action this happened, and what the error was. @RAMISAYAR
  • 49. • babel-plugin-react-transform wraps React components with arbitrary transforms. In other words, it allows you to instrument React components in any way—limited only by your imagination. • react-transform-hmr - enables hot reloading using HMR API • react-transform-catch-errors - catches errors inside render() • react-transform-debug-inspector - renders an inline prop inspector • react-transform-render-visualizer - highlight components when updated @RAMISAYAR
  • 51. • insin/nwb - Create React apps, components, libraries and other npm modules for use on the web with no configuration (until you need it). • mozilla/neo - Neo bakes in the best-of-the-bunch configurations and setup to make developing React-based sites quicker and easier. • NYTimes/kyt - Every sizable JavaScript web app needs a common foundation: a setup to build, run, test and lint your code. kyt is a toolkit that encapsulates and manages the configuration for web apps. @RAMISAYAR
  • 52. • MERN is the easiest way to build universal JavaScript apps using React and Redux. • MERN Starter - A powerful boilerplate project that gives you a solid head start on building universal React apps. • MERN cli - A command line utility that enables you to work with your MERN based projects easily by providing powerful code generation and scaffolding abilities. @RAMISAYAR
  • 53. • React Starter Kit is an opinionated boilerplate for web development built on top of Facebook's React library, Node.js / Express server and Flux architecture. • Containing modern web development tools such as Webpack, Babel and Browser Sync. @RAMISAYAR
  • 54. • A static website starter kit powered by React.js and Webpack. ✓ Generates static .html pages from React components ✓ Generates routes based on the list of files in the /pages folder ✓ Next generation JavaScript with Babel ✓ Sass syntax for CSS via postCSS and precss ✓ Development web server with BrowserSync and React Transform ✓ Bundling and optimization with Webpack ✓ Yeoman generator (generator-react-static) @RAMISAYAR
  • 56. • React Native by Facebook enables you to build on native platforms using JavaScript and React. • React Native focuses on developer efficiency — learn once, write anywhere. • Supports iOS and Android. @RAMISAYAR
  • 57. • Use standard platform components such as UITabBar on iOS and Drawer on Android. • Apps have a consistent look and feel with the rest of the platform ecosystem and have native performance. • Operations between JavaScript and the native platform are performed asynchronously. • Communication is fully serializable, allows you to debug the JavaScript while running the complete app, either in the simulator or on a physical device. @RAMISAYAR
  • 59. • Introduced React & the Ecosystem • What is Flux Architecture • Flux, Redux, Alt.js, etc. • Introduced React Libraries and UI Component Libraries • Introduced Relay, Falcor & React Resolver • Introduced React Native • Useful React Dev Tools @RAMISAYAR
  • 61. tw: @ramisayar | gh: @sayar @RAMISAYAR
  • 62. • https://www.toptal.com/react/navigating-the-react-ecosystem • https://github.com/enaqx/awesome-react • https://github.com/facebook/react/wiki/Complementary-Tools • http://slides.com/cguedes/a-tour-on-react-ecosystem @RAMISAYAR
  • 63. ©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.