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)

Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
 
React and redux
React and reduxReact and redux
React and redux
 
React JS - Introduction
React JS - IntroductionReact JS - Introduction
React JS - Introduction
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
React with Redux
React with ReduxReact with Redux
React with Redux
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
react redux.pdf
react redux.pdfreact redux.pdf
react redux.pdf
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
React Context API
React Context APIReact Context API
React Context API
 
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
 
Getting Started with NgRx (Redux) Angular
Getting Started with NgRx (Redux) AngularGetting Started with NgRx (Redux) Angular
Getting Started with NgRx (Redux) Angular
 
Introduction to react and redux
Introduction to react and reduxIntroduction to react and redux
Introduction to react and redux
 
Ngrx: Redux in angular
Ngrx: Redux in angularNgrx: Redux in angular
Ngrx: Redux in angular
 
learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to Hooks
 
React js
React jsReact js
React js
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 

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 lecture
React lectureReact lecture
React lecture
 
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
 
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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
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...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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, ...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

React & Redux