SlideShare a Scribd company logo
1 of 27
Download to read offline
The Productive
Developer Guide to
React
Maurice de Beijer
The Problem Solver
Microsoft Azure MVP
Freelance developer/instructor
Twitter: @mauricedb & @React_Tutorial
Web: http://www.TheProblemSolver.nl
E-mail: maurice.de.beijer@gmail.com
Who am I?
Is React reactive?
RxJS map operator
const Rx = require('rxjs'); 
const fetch = require('node‐fetch'); 
const url = 'http://api.themoviedb.org/3/movie/top_rated'; 
let movies = []; 
Rx.Observable 
  .range(1, 5) 
  .concatMap(page =>  
    fetch(`${url}?api_key=${process.env.API_KEY}&page=${page}`)) 
  .flatMap(rsp => rsp.json()) 
  .map(json => json.results)  
  .scan((prev, current) => prev.concat(current)) 
  .subscribe(item => movies = item); 
RxJS example
import React from 'react'; 
const Greeter = (props) => { 
    return ( 
        <div> 
            Hello {props.name} 
        </div> 
    ); 
}; 
export default Greeter;
A functional React component
WHAT IS REACT?
React is a JavaScript library
for building user interfaces
- Facebook
Create-React-App
The o cial React starter project
JSX is the language of choice
It combines ECMAScript and HTML markup
import React from 'react'; 
const Greeter = (props) => { 
    return ( 
        <div> 
            Hello {props.name} 
        </div> 
    ); 
}; 
export default Greeter;
JSX = Code with markup
ComponentsThe building blocks of a React application
React Components example
  1. import React, {Component} from 'react'; 
  2. import {path} from './config'; 
  3.  
  4. class Billboard extends Component { 
  5.   render() { 
  6.     const movie = this.props.movie; 
  7.      
  8.     return ( 
  9.       <div className="row"> 
 10.         <div className="title"> 
 11.           {movie.title} 
 12.         </div> 
import React from 'react'; 
import ReactDOM from 'react‐dom'; 
import App from './app'; 
ReactDOM.render(React.createElement(App),  
    document.getElementById('app'));
ReactDOMReactDOM renders the components into the DOM
Components & Props
Props are inputs to components
They should never be updated
Parent Components example
  1. import React, { PropTypes } from 'react'; 
  2. import Movie from './movie'; 
  3.  
  4. const MovieList = ({ movies }) => { 
  5.   return ( 
  6.     <div className="movie‐list"> 
  7.       {movies.map(movie => ( 
  8.         <Movie key={movie.id} 
  9.                movie={movie} 
 10.         />))} 
 11.     </div> 
 12.   ); 
Child Components example
  1. import React, { Component, PropTypes } from 
'react'; 
  2. import {path} from './config'; 
  3.  
  4. class Movie extends Component { 
  5.   render() { 
  6.     const { movie } = this.props; 
  7.  
  8.     return ( 
  9.       <div className="movie"> 
 10.         <div className="title"> 
 11.           {movie.title} 
Components & State
Internal to a component
Can be used as props for a child component
Stateful Components example
  1. import React, { Component } from 'react'; 
  2. import MovieList from './movie‐list'; 
  3.  
  4. class MovieContainer extends Component { 
  5.   constructor(props) { 
  6.     super(props); 
  7.  
  8.     this.state = { 
  9.       movies: null, 
 10.     }; 
 11.   } 
 12.  
ReduxA predictable state container for JavaScript apps
Redux principles
Single source of truth
State is read-only
Changes are made with pure functions
Redux reducer
  1. function todos(state = [], action) { 
  2.   switch (action.type) { 
  3.     case ADD_TODO: 
  4.       return [ 
  5.         ...state, 
  6.         { 
  7.           text: action.text, 
  8.           completed: false 
  9.         } 
 10.       ] 
 11.     case TOGGLE_TODO: 
 12.       return state.map((todo, index) => { 
MobXSimple, scalable state management
MobX principles
Single source of truth
State is observable
React components are observers
MobX observers
  1. import React, { PropTypes } from 'react'; 
  2. import { observable } from 'mobx' 
  3. import { observer } from 'mobx‐react'; 
  4. import Movie from './movie'; 
  5.  
  6. class MovieStore { 
  7.     @observable movies = []; 
  8.     @observable directors = []; 
  9. } 
 10.  
 11.  
 12. const MovieList = observer(({ movies }) => { 
Is React reactive?
     NO!     But it's a great library for building user interfaces
And MobX is reactive!
@mauricedb

More Related Content

What's hot

What's hot (20)

Microservices for the Masses with Spring Boot, JHipster, and JWT - Devoxx UK...
 Microservices for the Masses with Spring Boot, JHipster, and JWT - Devoxx UK... Microservices for the Masses with Spring Boot, JHipster, and JWT - Devoxx UK...
Microservices for the Masses with Spring Boot, JHipster, and JWT - Devoxx UK...
 
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 .
 
Grails Spring Boot
Grails Spring BootGrails Spring Boot
Grails Spring Boot
 
React js Online Training
React js Online TrainingReact js Online Training
React js Online Training
 
React JS
React JSReact JS
React JS
 
Lviv MD Day 2015 Іван Лаврів "Mobile development with React Native"
Lviv MD Day 2015 Іван Лаврів "Mobile development with React Native"Lviv MD Day 2015 Іван Лаврів "Mobile development with React Native"
Lviv MD Day 2015 Іван Лаврів "Mobile development with React Native"
 
Internal workshop react-js-mruiz
Internal workshop react-js-mruizInternal workshop react-js-mruiz
Internal workshop react-js-mruiz
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6
 
Vue.js Use Cases
Vue.js Use CasesVue.js Use Cases
Vue.js Use Cases
 
Angular based enterprise level frontend architecture
Angular based enterprise level frontend architectureAngular based enterprise level frontend architecture
Angular based enterprise level frontend architecture
 
Reactjs
Reactjs Reactjs
Reactjs
 
Say hello to react js - Day 1
Say hello to react js   - Day 1Say hello to react js   - Day 1
Say hello to react js - Day 1
 
Meteor.js for DOers
Meteor.js for DOersMeteor.js for DOers
Meteor.js for DOers
 
Putting the Native in React Native - React Native Boston
Putting the Native in React Native - React Native BostonPutting the Native in React Native - React Native Boston
Putting the Native in React Native - React Native Boston
 
ReactJs
ReactJsReactJs
ReactJs
 
Java microservicesspringbootcasestudy2
Java microservicesspringbootcasestudy2Java microservicesspringbootcasestudy2
Java microservicesspringbootcasestudy2
 
Micro Frontends
Micro FrontendsMicro Frontends
Micro Frontends
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core Concepts
 
Building Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & AzureBuilding Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & Azure
 
Web worker in your angular application
Web worker in your angular applicationWeb worker in your angular application
Web worker in your angular application
 

Viewers also liked

Viewers also liked (20)

Intro To React Native
Intro To React NativeIntro To React Native
Intro To React Native
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react native
 
React Native
React NativeReact Native
React Native
 
Baromètre IDAOS Lab "Digital & Social" 3ème édition 2015
Baromètre IDAOS Lab "Digital & Social" 3ème édition 2015Baromètre IDAOS Lab "Digital & Social" 3ème édition 2015
Baromètre IDAOS Lab "Digital & Social" 3ème édition 2015
 
Slide online
Slide onlineSlide online
Slide online
 
How to Earn the Attention of Today's Buyer
How to Earn the Attention of Today's BuyerHow to Earn the Attention of Today's Buyer
How to Earn the Attention of Today's Buyer
 
Why People Block Ads (And What It Means for Marketers and Advertisers) [New R...
Why People Block Ads (And What It Means for Marketers and Advertisers) [New R...Why People Block Ads (And What It Means for Marketers and Advertisers) [New R...
Why People Block Ads (And What It Means for Marketers and Advertisers) [New R...
 
What is Inbound Recruiting?
What is Inbound Recruiting?What is Inbound Recruiting?
What is Inbound Recruiting?
 
Add the Women Back: Wikipedia Edit-a-Thon
Add the Women Back: Wikipedia Edit-a-ThonAdd the Women Back: Wikipedia Edit-a-Thon
Add the Women Back: Wikipedia Edit-a-Thon
 
Isolated React Js components
Isolated React Js componentsIsolated React Js components
Isolated React Js components
 
深入淺出RoR
深入淺出RoR深入淺出RoR
深入淺出RoR
 
React native. Bridge From Web To Mobile. Intro
React native. Bridge From Web To Mobile. IntroReact native. Bridge From Web To Mobile. Intro
React native. Bridge From Web To Mobile. Intro
 
React Native Intro
React Native IntroReact Native Intro
React Native Intro
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
React Native + Redux
React Native + ReduxReact Native + Redux
React Native + Redux
 
Introduzione al Regolamento Generale sulla Protezione dei Dati dell’ Unione E...
Introduzione al Regolamento Generale sulla Protezione dei Dati dell’ Unione E...Introduzione al Regolamento Generale sulla Protezione dei Dati dell’ Unione E...
Introduzione al Regolamento Generale sulla Protezione dei Dati dell’ Unione E...
 
Navigation in React Native
Navigation in React NativeNavigation in React Native
Navigation in React Native
 
Styling React Native Applications
Styling React Native ApplicationsStyling React Native Applications
Styling React Native Applications
 
Sintesis informativa 28 de marzo 2017
Sintesis informativa 28 de marzo 2017Sintesis informativa 28 de marzo 2017
Sintesis informativa 28 de marzo 2017
 
1.2.3 Система напольных шкафов RAM block
1.2.3 Система напольных шкафов RAM block1.2.3 Система напольных шкафов RAM block
1.2.3 Система напольных шкафов RAM block
 

Similar to Is React reactive?

Секретный доклад о React Router - OdessaJS 2014
Секретный доклад о React Router - OdessaJS 2014Секретный доклад о React Router - OdessaJS 2014
Секретный доклад о React Router - OdessaJS 2014
Andrey Listochkin
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Provectus
 

Similar to Is React reactive? (20)

From zero to hero with the reactive extensions for JavaScript
From zero to hero with the reactive extensions for JavaScriptFrom zero to hero with the reactive extensions for JavaScript
From zero to hero with the reactive extensions for JavaScript
 
From zero to hero with the reactive extensions for java script
From zero to hero with the reactive extensions for java scriptFrom zero to hero with the reactive extensions for java script
From zero to hero with the reactive extensions for java script
 
React & The Art of Managing Complexity
React &  The Art of Managing ComplexityReact &  The Art of Managing Complexity
React & The Art of Managing Complexity
 
jsDay 2016 recap
jsDay 2016 recapjsDay 2016 recap
jsDay 2016 recap
 
Oracle APEX migration to 5.1 - Our experience
Oracle APEX migration to 5.1 - Our experienceOracle APEX migration to 5.1 - Our experience
Oracle APEX migration to 5.1 - Our experience
 
RxJS Operators - Real World Use Cases (FULL VERSION)
RxJS Operators - Real World Use Cases (FULL VERSION)RxJS Operators - Real World Use Cases (FULL VERSION)
RxJS Operators - Real World Use Cases (FULL VERSION)
 
Секретный доклад о React Router - OdessaJS 2014
Секретный доклад о React Router - OdessaJS 2014Секретный доклад о React Router - OdessaJS 2014
Секретный доклад о React Router - OdessaJS 2014
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014
 
Cycle.js - A functional reactive UI framework
Cycle.js - A functional reactive UI frameworkCycle.js - A functional reactive UI framework
Cycle.js - A functional reactive UI framework
 
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatient
 
Rx java in action
Rx java in actionRx java in action
Rx java in action
 
How to unit test your React/Redux app
How to unit test your React/Redux appHow to unit test your React/Redux app
How to unit test your React/Redux app
 
Luis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio on RxJS
Luis Atencio on RxJS
 
Architecture for scalable Angular applications
Architecture for scalable Angular applicationsArchitecture for scalable Angular applications
Architecture for scalable Angular applications
 
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
 
Rxjs marble-testing
Rxjs marble-testingRxjs marble-testing
Rxjs marble-testing
 
Workshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSWorkshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJS
 

More from Maurice De Beijer [MVP]

More from Maurice De Beijer [MVP] (20)

Practice TypeScript Techniques Building React Server Components App
Practice TypeScript Techniques Building React Server Components AppPractice TypeScript Techniques Building React Server Components App
Practice TypeScript Techniques Building React Server Components App
 
A foolproof Way to Estimate a Software Project
A foolproof Way to Estimate a Software ProjectA foolproof Way to Estimate a Software Project
A foolproof Way to Estimate a Software Project
 
Surati Tech Talks 2022 / Build reliable Svelte applications using Cypress
Surati Tech Talks 2022 / Build reliable Svelte applications using CypressSurati Tech Talks 2022 / Build reliable Svelte applications using Cypress
Surati Tech Talks 2022 / Build reliable Svelte applications using Cypress
 
Build reliable Svelte applications using Cypress
Build reliable Svelte applications using CypressBuild reliable Svelte applications using Cypress
Build reliable Svelte applications using Cypress
 
Concurrent Rendering Adventures in React 18
Concurrent Rendering Adventures in React 18Concurrent Rendering Adventures in React 18
Concurrent Rendering Adventures in React 18
 
Building reliable applications with React, C#, and Azure
Building reliable applications with React, C#, and AzureBuilding reliable applications with React, C#, and Azure
Building reliable applications with React, C#, and Azure
 
Building large and scalable mission critical applications with React
Building large and scalable mission critical applications with ReactBuilding large and scalable mission critical applications with React
Building large and scalable mission critical applications with React
 
Building Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & AzureBuilding Reliable Applications Using React, .NET & Azure
Building Reliable Applications Using React, .NET & Azure
 
Why I am hooked on the future of React
Why I am hooked on the future of ReactWhy I am hooked on the future of React
Why I am hooked on the future of React
 
Building reliable web applications using Cypress
Building reliable web applications using CypressBuilding reliable web applications using Cypress
Building reliable web applications using Cypress
 
Getting started with React Suspense and concurrent rendering
Getting started with React Suspense and concurrent renderingGetting started with React Suspense and concurrent rendering
Getting started with React Suspense and concurrent rendering
 
React suspense, not just for Alfred Hitchcock
React suspense, not just for Alfred HitchcockReact suspense, not just for Alfred Hitchcock
React suspense, not just for Alfred Hitchcock
 
From zero to hero with the Reactive extensions for JavaScript
From zero to hero with the Reactive extensions for JavaScriptFrom zero to hero with the Reactive extensions for JavaScript
From zero to hero with the Reactive extensions for JavaScript
 
Why I am hooked on the future of React
Why I am hooked on the future of ReactWhy I am hooked on the future of React
Why I am hooked on the future of React
 
The new React
The new React The new React
The new React
 
From zero to hero with the reactive extensions for JavaScript
From zero to hero with the reactive extensions for JavaScriptFrom zero to hero with the reactive extensions for JavaScript
From zero to hero with the reactive extensions for JavaScript
 
Why I am hooked on the future of React
Why I am hooked on the future of ReactWhy I am hooked on the future of React
Why I am hooked on the future of React
 
I am hooked on React
I am hooked on ReactI am hooked on React
I am hooked on React
 
Create flexible React applications using GraphQL apis
Create flexible React applications using GraphQL apisCreate flexible React applications using GraphQL apis
Create flexible React applications using GraphQL apis
 
Create flexible react applications using GraphQL API's
Create flexible react applications using GraphQL API'sCreate flexible react applications using GraphQL API's
Create flexible react applications using GraphQL API's
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Is React reactive?