SlideShare a Scribd company logo
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

PPTX
React / Redux Architectures
PDF
React js use contexts and useContext hook
PPTX
React + Redux Introduction
PDF
Introduction to Redux
PPTX
React js programming concept
PPTX
React state
PPTX
React hooks
PDF
Understanding react hooks
React / Redux Architectures
React js use contexts and useContext hook
React + Redux Introduction
Introduction to Redux
React js programming concept
React state
React hooks
Understanding react hooks

What's hot (20)

PPTX
Redux training
PDF
React new features and intro to Hooks
PDF
Workshop 21: React Router
PDF
An introduction to React.js
PPTX
React hooks
PPTX
Intro to React
PDF
React Router: React Meetup XXL
PPTX
React workshop
PDF
React and redux
PPTX
Introduction to react_js
PPTX
Introduction to React
PPTX
Introduction to React JS for beginners
PPTX
React web development
PPTX
Redux workshop
PDF
React JS - Introduction
PDF
PPTX
React js
PDF
Important React Hooks
ODP
Introduction to ReactJS
Redux training
React new features and intro to Hooks
Workshop 21: React Router
An introduction to React.js
React hooks
Intro to React
React Router: React Meetup XXL
React workshop
React and redux
Introduction to react_js
Introduction to React
Introduction to React JS for beginners
React web development
Redux workshop
React JS - Introduction
React js
Important React Hooks
Introduction to ReactJS
Ad

Similar to React & Redux (20)

PDF
React lecture
PPTX
React + Flux = Joy
PDF
Integrating React.js with PHP projects
PPTX
React/Redux
PDF
ReactJS
PDF
An Intense Overview of the React Ecosystem
PDF
An Overview of the React Ecosystem
PDF
The Road To Redux
PDF
Mastering-Reactjs-Your-Path-to-Web-Development.pdf
PDF
Let's discover React and Redux with TypeScript
PPTX
Introduction to react and redux
PDF
React Interview Question & Answers PDF By ScholarHat
PDF
Stay with React.js in 2020
PPTX
The productive developer guide to React
PPTX
Reactjs notes.pptx for web development- tutorial and theory
PPTX
React.js - The Dawn of Virtual DOM
PPTX
PPTX
React_Complete.pptx
PPTX
reactJS
PPSX
React introduction
React lecture
React + Flux = Joy
Integrating React.js with PHP projects
React/Redux
ReactJS
An Intense Overview of the React Ecosystem
An Overview of the React Ecosystem
The Road To Redux
Mastering-Reactjs-Your-Path-to-Web-Development.pdf
Let's discover React and Redux with TypeScript
Introduction to react and redux
React Interview Question & Answers PDF By ScholarHat
Stay with React.js in 2020
The productive developer guide to React
Reactjs notes.pptx for web development- tutorial and theory
React.js - The Dawn of Virtual DOM
React_Complete.pptx
reactJS
React introduction
Ad

Recently uploaded (20)

PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
1. Introduction to Computer Programming.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPT
Teaching material agriculture food technology
PPTX
Tartificialntelligence_presentation.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
August Patch Tuesday
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
A comparative analysis of optical character recognition models for extracting...
1. Introduction to Computer Programming.pptx
Network Security Unit 5.pdf for BCA BBA.
cloud_computing_Infrastucture_as_cloud_p
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Machine Learning_overview_presentation.pptx
Encapsulation theory and applications.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Group 1 Presentation -Planning and Decision Making .pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Teaching material agriculture food technology
Tartificialntelligence_presentation.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Univ-Connecticut-ChatGPT-Presentaion.pdf
August Patch Tuesday
Encapsulation_ Review paper, used for researhc scholars
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

React & Redux