SlideShare a Scribd company logo
1 of 30
Download to read offline
REACT 101
INTRODUCTION FOR DEVELOPERS
REACT
A JavaScript library for
building UIs, developed by
Facebook.
COMPANIES USING REACT
render

State -> View
STATE
[
“Design incredible app”,
“Something happens”,
“Collect profits”
]
VIEW
<ol>
<li>Design incredible app </li>
<li>Something happens </li>
<li>Collect profits </li>
</ol>
VIRTUAL DOM
DEFINING COMPONENTS
function MyComponent(state) {
return (
<span className=“counter”>
{state.count}
</span>
)
}
DEFINING COMPONENTS
function MyComponent(props) {
return (
<span className=“counter”>
{props.count}
</span>
);
}
RENDERING COMPONENTS
ReactDOM.render(
<MyComponent count={5} />
document.getElementById(‘root’)
);
CLASS-BASED COMPONENTS
var MyComponent = React.createClass({
render: function() {
return (
<span className=“counter”>
{this.props.count}
</span>
);
}
}
CLASS BASED COMPONENTS (ECMASCRIPT 6 FTW!)
const MyComponent = React.createClass({
render() {
return (
<span className=“counter”>
{this.props.count}
</span>
);
}
}
INTERACTIVITY
const MyComponent = React.createClass({
getInitialState() {
return { count: 0 };
}
handleClick(event) {
this.setState({ count: count + 1 });
},
render() {
return (
<span className=“counter”
onClick={this.handleClick}>
{this.state.count}
</span>
);
}
}
PROP TYPE-CHECKING
const MyComponent = React.createClass({
propTypes: {
count: React.PropTypes
},
...
}
ROUTING WITH REACT-ROUTER
ReactDOM.render((
<Router history={browserHistory}>
<Route path="/" component={App}>
<Route path="tasks" component={Tasks} />
<Route path="/task/:taskId" component={TaskDetails} />
<Route path="*" component={NoMatch} />
</Route>
</Router>
), document.body)
INTERNATIONALIZATION WITH REACT-INTL
const MyComponent = React.createClass({
mixins: [IntlMixin],
render() {
return (
<span className=“counter”>
{this.getIntlMessage(‘counter.label’)}
</span>
);
}
}
FLUX ARCHITECTURE
REDUX
Predictable state container for
React developed by Dan
Abramov.
store
(State, Action) -> State
PRINCIPLES
➤ Single source of truth
➤ Read-only state
➤ Changes are made with pure functions
ACTIONS
function createTask(description) {
return {
type: ‘CREATE_TASK’,
description: description
};
}
STORE INTERFACE
store.dispatch(
actions.createTask(”Do homework.”)
);
store.getState();
store.subscribe(function(state) {
// do something when state changes
});
REDUX BINDINGS FOR REACT
<Provider store={store}>
…
</Provider>
———————————————————————————————————————————————————
connect((state) => {
counter: state.counter
})(MyComponent)
ASYNC ACTIONS
function createTask(description) {
return function(dispatch, getState) {
dispatch({ type: ‘CREATE_TASK’, description });
fetch(‘/api/tasks’).then((response) => {
dispatch(actions.loadTasks(response.json()))
});
};
}
* requires redux-thunk middleware for Redux
REDUCERS
function reducer(state, action) {
if (action.type == ‘CREATE_TASK’) {
return [action.description, …state];
}
return state;
}
ONE MORE THING…
➤ Design your state carefully.
➤ Use Flux Standard Action for your action types.
➤ Avoid side-effects in your reducers.
➤ Use Immutable.js to enforce immutability.
DEVTOOLS
➤ React Developer Tools for Chrome
➤ Elements-like panel for virtual DOM.
➤ Redux DevTools (sidebar panel)
➤ Complete visibility over actions and state, time-traveling.
SUMMARY
➤ React code looks just like plain JavaScript.
➤ React gives you much more freedom to architect your app, but
that usually means more time spent configuring it.
➤ Not much work done in standardizing React apps.

Flux Standard Action is a start.
Questions?
Thanks!
Federico Bond
Co-Founder & CTO

BitCourt
@federicobond
federicobond

More Related Content

What's hot

What's hot (20)

ReactJS
ReactJSReactJS
ReactJS
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
React JS - Introduction
React JS - IntroductionReact JS - Introduction
React JS - Introduction
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 
React workshop
React workshopReact workshop
React workshop
 
Reactjs
ReactjsReactjs
Reactjs
 
React hooks
React hooksReact hooks
React hooks
 
React.js and Redux overview
React.js and Redux overviewReact.js and Redux overview
React.js and Redux overview
 
React lecture
React lectureReact lecture
React lecture
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
ReactJs
ReactJsReactJs
ReactJs
 
Getting started with Redux js
Getting started with Redux jsGetting started with Redux js
Getting started with Redux js
 
Introduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace ITIntroduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace IT
 
React js
React jsReact js
React js
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
React Context API
React Context APIReact Context API
React Context API
 
ReactJS
ReactJSReactJS
ReactJS
 

Similar to React & Redux

Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to production
FDConf
 

Similar to React & Redux (20)

Reactивная тяга
Reactивная тягаReactивная тяга
Reactивная тяга
 
Manage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's ReduxManage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's Redux
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creators
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
 
Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3 Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3
 
React redux
React reduxReact redux
React redux
 
Learning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User InterfacesLearning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User Interfaces
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & Redux
 
Recompacting your react application
Recompacting your react applicationRecompacting your react application
Recompacting your react application
 
Understanding redux
Understanding reduxUnderstanding redux
Understanding redux
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
 
Egghead redux-cheat-sheet-3-2-1
Egghead redux-cheat-sheet-3-2-1Egghead redux-cheat-sheet-3-2-1
Egghead redux-cheat-sheet-3-2-1
 
Intro to React | DreamLab Academy
Intro to React | DreamLab AcademyIntro to React | DreamLab Academy
Intro to React | DreamLab Academy
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to production
 
React 101
React 101React 101
React 101
 
React и redux
React и reduxReact и redux
React и redux
 
Full Stack Toronto - the 3R Stack
Full Stack Toronto - the 3R StackFull Stack Toronto - the 3R Stack
Full Stack Toronto - the 3R Stack
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to production
 
Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)
Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)
Indeed My Jobs: A case study in ReactJS and Redux (Meetup talk March 2016)
 
React outbox
React outboxReact outbox
React outbox
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

React & Redux