SlideShare a Scribd company logo
R E A C T
F O R B E G I N N E R S
W H O A M I
• Derek Stavis
• Software Engineer @ Healfies
• Coding stuff since 2000
• High level stuff
• Low level stuff
• Design stuff
• github.com/derekstavis
• github.com/oh-my-fish
• Why React?
• Components
• Tooling
• How not to start
• Step by step demo
W H Y R E A C T ?
W H Y R E A C T
• Declarative syntax
• Does one thing and do it well
• Think components, not controllers
• User Interfaces as a function of data
• DOM abstraction (a.k.a. Virtual DOM)
D O O N E T H I N G A N D D O I T W E L L
• React has no…
• Dependency injection
• Automagic data binding
• Controllers
• Directives
• Templates
T H I N K C O M P O N E N T S ,
N O T C O N T R O L L E R S
• Everything is a component
• Application
• Router
• Data Store
• Widgets
T H I N K C O M P O N E N T S ,
N O T C O N T R O L L E R S
• Well designed components are
• Composable
• Reusable
• Maintainable
• Testable
U I A S A F U N C T I O N O F D ATA
• Element tree is a result of function application
• Never operate on global, shared state
• Data flow is unidirectional
V I R T U A L D O M
• Abstraction
• Performance
• Reconciliation
• Isomorphism
C O M P O N E N T
S P E C S A N D L I F E C Y C L E
C O M P O N E N T
D E C L A R AT I O N *
<Button

label='Click me'

onClick={this.foo.bind(this)}

/>
Props
* wow, such directives
Pattern: Break the line to close tag and clean the indentation
C O M P O N E N T
S P E C I F I C AT I O N
• const Component = React.createClass
• class Component extends React.Component
C O M P O N E N T
S P E C I F I C AT I O N
• React.createClass
• getInitialState
• getDefaultProps
• propTypes
• render
C O M P O N E N T
S P E C I F I C AT I O N
• class Component extends React.Component
• Component.propTypes
• Component.defaultProps
• this.state
• render
const Title = (props) => <h1>props.title</h1>
S TAT E L E S S C O M P O N E N T
S P E C I F I C AT I O N
C O M P O N E N T L I F E C Y C L E
• componentWillMount
• componentDidMount
• componentWillReceiveProps
• shouldComponentUpdate
• componentWillUpdate
• componentDidUpdate
• componentWillUnmount
C O M P O N E N T D ATA I N T E R FA C E
• component.props
• component.state
C O M P O N E N T D ATA F L O W
• React is one way data binding
• Data only flows down in tree
• State changes are explicit
C O M P O N E N T D ATA F L O W
• Data only flows down in tree
C O M P O N E N T D ATA F L O W
• Events flow up in tree
T O O L I N G
W H A T M A K E S R E A C T A W E S O M E
E S 6 O R N O T E S 6
React encourages ES6
E S 6 O R N O T E S 6
const makeCellTitle = (props) => {
const { title, description } = props
return `${title}: ${description}`
}
var title = 'Hello World'
var description = 'A classic programmer thing'
makeCellTitle({ title, description })
> Hello World: A classic programmer thing
const makeCellTitle = (props) => {
const { title, description } = props
return `${title}: ${description}`
}
var title = 'Hello World'
var description = 'A classic programmer thing'
makeCellTitle({ title, description })
> Hello World: A classic programmer thing
const makeCellTitle = (props) => {
const { title, description } = props
return `${title}: ${description}`
}
var title = 'Hello World'
var description = 'A classic programmer thing'
makeCellTitle({ title, description })
> Hello World: A classic programmer thing
E S 6 O R N O T E S 6
A R R O W
F U N C T I O N S
const makeCellTitle = (props) => {
const { title, description } = props
return `${title}: ${description}`
}
var title = 'Hello World'
var description = 'A classic programmer thing'
makeCellTitle({ title, description })
> Hello World: A classic programmer thing
const makeCellTitle = (props) => {
const { title, description } = props
return `${title}: ${description}`
}
var title = 'Hello World'
var description = 'A classic programmer thing'
makeCellTitle({ title, description })
> Hello World: A classic programmer thing
E S 6 O R N O T E S 6
D E S T R U C T U R I N G
E S 6 O R N O T E S 6
const makeCellTitle = (props) => {
const { title, description } = props
return `${title}: ${description}`
}
var title = 'Hello World'
var description = 'A classic programmer thing'
makeCellTitle({ title, description })
> Hello World: A classic programmer thing
const makeCellTitle = (props) => {
const { title, description } = props
return `${title}: ${description}`
}
var title = 'Hello World'
var description = 'A classic programmer thing'
makeCellTitle({ title, description })
> Hello World: A classic programmer thing
S T R I N G
I N T E R P O L AT I O N
const makeCellTitle = (props) => {
const { title, description } = props
return `${title}: ${description}`
}
var title = 'Hello World'
var description = 'A classic programmer thing'
makeCellTitle({ title, description })
> Hello World: A classic programmer thing
E S 6 O R N O T E S 6
A R R O W
F U N C T I O N S
S T R I N G
I N T E R P O L AT I O N
D E S T R U C T U R I N G
E S 6 O R N O T E S 6
• Native class syntax
• Arrow functions
• String interpolation
• Destructuring
• Code for the future
const makeCellTitle = (props) => {
const { title, description } = props
return `${title}: ${description}`
}
var title = 'Hello World'
var description = 'A classic programmer thing'
makeCellTitle({ title, description })
> Hello World: A classic programmer thing
A R R O W
F U N C T I O N S
S T R I N G
I N T E R P O L AT I O N
D E S T R U C T U R I N G
J S X O R N O T J S X
React encourages JSX
J S X O R N O T J S X
render() {
return (
<div>
<h1>A counter example</h1>
<div>Current value is {this.state.counter}</div>
<button onClick={this.handleButton.bind(this)}>
Increase
</button>
</div>
)
}
render() {
return (
<div>
<h1>A counter example</h1>
<div>Current value is {this.state.counter}</div>
<button onClick={this.handleButton.bind(this)}>
Increase
</button>
</div>
)
}
J S X O R N O T J S X
• It's like HTML in side JavaScript
• In reality it's just syntactic sugar
• Transforms into plain JavaScript
J S X O R N O T J S X
render() {
return React.createElement(
'div', null,
React.createElement(
'h1', null,
'A counter example'
),
React.createElement(
'div', null,
'Current value is ',
this.state.counter
),
React.createElement(
'button',
{ onClick: this.handleButton.bind(this) },
'Increase'
)
)
}
J S X O R N O T J S X
Use JSX, for the sake of sanity
T R A N S F O R M I N G J S X
• In-browser transform
• More stuff to download
• Slower due to compilation
• Precompiled JS assets
• Fast for the client
• Integrated into build
M A I N S T R E A M T O O L I N G
• Babel
• JavaScript Compiler
• ES6 → ES5
• JSX → JavaScript
M A I N S T R E A M T O O L I N G
• Webpack
• Module bundler
• Join npm packages and your code
• Apply loaders that transform files
M A I N S T R E A M T O O L I N G
J S X J S ( E S 5 )
babel-loader
S C S S C S S
postcss-loader
P N G B A S E 6 4
file-loader
B U N D L E . J S
T O O L I N G
The stack looks complicated
T O O L I N G
• Don't start with a boilerplate
• github.com/gaearon/react-makes-you-sad
D O N ' T S TA R T W I T H B O I L E R P L AT E
T O O L I N G
Understand the parts first
D E M O T I M E
S T E P B Y S T E P R E A C T P R O J E C T
U S I N G B A B E L A N D W E B PA C K
D E M O T I M E
http://tiny.cc/react-beginners-demo
R E F E R E N C E S
• facebook.github.io/react/docs/component-api.html
• facebook.github.io/react/docs/component-specs.html
T H A N K S
Q U E S T I O N S ?
L I C E N S E
• Copyright 2016 © Derek W. Stavis
• Attribution-ShareAlike 4.0 International

More Related Content

PDF
Introduction to React JS
PPTX
React JS - A quick introduction tutorial
PDF
Angular Dependency Injection
PDF
Angular Observables & RxJS Introduction
PDF
introduction to Vue.js 3
PDF
NodeJS for Beginner
PPT
React js
PDF
Introduction to React JS
React JS - A quick introduction tutorial
Angular Dependency Injection
Angular Observables & RxJS Introduction
introduction to Vue.js 3
NodeJS for Beginner
React js

What's hot (20)

PPTX
React js for beginners
PPTX
Express JS
PPTX
Intro to React
PPTX
PDF
An Introduction to ReactJS
PPTX
PPTX
Reactjs
PPTX
React workshop
PPTX
Intro to React
PPTX
React js programming concept
PPTX
[Final] ReactJS presentation
PDF
An introduction to React.js
PPTX
Angular Data Binding
ODP
Introduction to ReactJS
PDF
Reactjs workshop (1)
PPTX
React + Redux Introduction
PPTX
Build RESTful API Using Express JS
PPTX
React JS part 1
PDF
React JS - Introduction
PDF
ES6 presentation
React js for beginners
Express JS
Intro to React
An Introduction to ReactJS
Reactjs
React workshop
Intro to React
React js programming concept
[Final] ReactJS presentation
An introduction to React.js
Angular Data Binding
Introduction to ReactJS
Reactjs workshop (1)
React + Redux Introduction
Build RESTful API Using Express JS
React JS part 1
React JS - Introduction
ES6 presentation
Ad

Viewers also liked (6)

PDF
Introduction to node.js, npm and grunt
PDF
Jaap : node, npm & grunt
PPTX
Front end task automation using grunt, yeoman and npm(1)
PDF
Workshop 3: JavaScript build tools
PPTX
Building modern share point apps (angularjs, npm, bower, grunt, VS2015)
PDF
Forget Grunt and Gulp! Webpack and NPM rule them all!
Introduction to node.js, npm and grunt
Jaap : node, npm & grunt
Front end task automation using grunt, yeoman and npm(1)
Workshop 3: JavaScript build tools
Building modern share point apps (angularjs, npm, bower, grunt, VS2015)
Forget Grunt and Gulp! Webpack and NPM rule them all!
Ad

Similar to React for Beginners (20)

PDF
An Introduction to React -- FED Date -- IBM Design
PDF
React Development with the MERN Stack
PPTX
React & Redux for noobs
PPTX
React JS: A Secret Preview
PPTX
React_Complete.pptx
PDF
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
PPTX
React Workshop: Core concepts of react
PPTX
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
PDF
The Road To Redux
DOCX
What are Props Concept in React JS Course
DOCX
Props concepts in React JS Course for beginners .docx
PDF
2018 05-16 Evolving Technologies: React, Babel & Webpack
PDF
ReactJS for Programmers
PPTX
React.js - The Dawn of Virtual DOM
PDF
React lecture
PDF
unit 3_Adv WTAdvanced Web Tecg Design_HTML_CSS_JAVASCRIPT_AJAX_PPT.pdf
PPTX
2.React tttttttttttttttttttttttttttttttt
PDF
React for Dummies
PPTX
Reactjs notes.pptx for web development- tutorial and theory
PDF
Lezione 03 Introduzione a react
An Introduction to React -- FED Date -- IBM Design
React Development with the MERN Stack
React & Redux for noobs
React JS: A Secret Preview
React_Complete.pptx
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
React Workshop: Core concepts of react
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
The Road To Redux
What are Props Concept in React JS Course
Props concepts in React JS Course for beginners .docx
2018 05-16 Evolving Technologies: React, Babel & Webpack
ReactJS for Programmers
React.js - The Dawn of Virtual DOM
React lecture
unit 3_Adv WTAdvanced Web Tecg Design_HTML_CSS_JAVASCRIPT_AJAX_PPT.pdf
2.React tttttttttttttttttttttttttttttttt
React for Dummies
Reactjs notes.pptx for web development- tutorial and theory
Lezione 03 Introduzione a react

More from Derek Willian Stavis (7)

PDF
React performance
PDF
JavaScript Event Loop
PDF
Node.js cluster
PDF
Packing it all: JavaScript module bundling from 2000 to now
PDF
Ramda, a functional JavaScript library
PDF
JavaScript Promises
PDF
Introdução ao MongoDB em 30 slides
React performance
JavaScript Event Loop
Node.js cluster
Packing it all: JavaScript module bundling from 2000 to now
Ramda, a functional JavaScript library
JavaScript Promises
Introdução ao MongoDB em 30 slides

Recently uploaded (20)

PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Digital Strategies for Manufacturing Companies
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Nekopoi APK 2025 free lastest update
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
medical staffing services at VALiNTRY
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
AI in Product Development-omnex systems
PPTX
ai tools demonstartion for schools and inter college
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Operating system designcfffgfgggggggvggggggggg
Softaken Excel to vCard Converter Software.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Design an Analysis of Algorithms I-SECS-1021-03
Digital Strategies for Manufacturing Companies
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Nekopoi APK 2025 free lastest update
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
medical staffing services at VALiNTRY
How to Choose the Right IT Partner for Your Business in Malaysia
Understanding Forklifts - TECH EHS Solution
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
AI in Product Development-omnex systems
ai tools demonstartion for schools and inter college
PTS Company Brochure 2025 (1).pdf.......
Wondershare Filmora 15 Crack With Activation Key [2025
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Odoo POS Development Services by CandidRoot Solutions
Operating system designcfffgfgggggggvggggggggg

React for Beginners

  • 1. R E A C T F O R B E G I N N E R S
  • 2. W H O A M I • Derek Stavis • Software Engineer @ Healfies • Coding stuff since 2000 • High level stuff • Low level stuff • Design stuff • github.com/derekstavis • github.com/oh-my-fish
  • 3. • Why React? • Components • Tooling • How not to start • Step by step demo
  • 4. W H Y R E A C T ?
  • 5. W H Y R E A C T • Declarative syntax • Does one thing and do it well • Think components, not controllers • User Interfaces as a function of data • DOM abstraction (a.k.a. Virtual DOM)
  • 6. D O O N E T H I N G A N D D O I T W E L L • React has no… • Dependency injection • Automagic data binding • Controllers • Directives • Templates
  • 7. T H I N K C O M P O N E N T S , N O T C O N T R O L L E R S • Everything is a component • Application • Router • Data Store • Widgets
  • 8. T H I N K C O M P O N E N T S , N O T C O N T R O L L E R S • Well designed components are • Composable • Reusable • Maintainable • Testable
  • 9. U I A S A F U N C T I O N O F D ATA • Element tree is a result of function application • Never operate on global, shared state • Data flow is unidirectional
  • 10. V I R T U A L D O M • Abstraction • Performance • Reconciliation • Isomorphism
  • 11. C O M P O N E N T S P E C S A N D L I F E C Y C L E
  • 12. C O M P O N E N T D E C L A R AT I O N * <Button
 label='Click me'
 onClick={this.foo.bind(this)}
 /> Props * wow, such directives Pattern: Break the line to close tag and clean the indentation
  • 13. C O M P O N E N T S P E C I F I C AT I O N • const Component = React.createClass • class Component extends React.Component
  • 14. C O M P O N E N T S P E C I F I C AT I O N • React.createClass • getInitialState • getDefaultProps • propTypes • render
  • 15. C O M P O N E N T S P E C I F I C AT I O N • class Component extends React.Component • Component.propTypes • Component.defaultProps • this.state • render
  • 16. const Title = (props) => <h1>props.title</h1> S TAT E L E S S C O M P O N E N T S P E C I F I C AT I O N
  • 17. C O M P O N E N T L I F E C Y C L E • componentWillMount • componentDidMount • componentWillReceiveProps • shouldComponentUpdate • componentWillUpdate • componentDidUpdate • componentWillUnmount
  • 18. C O M P O N E N T D ATA I N T E R FA C E • component.props • component.state
  • 19. C O M P O N E N T D ATA F L O W • React is one way data binding • Data only flows down in tree • State changes are explicit
  • 20. C O M P O N E N T D ATA F L O W • Data only flows down in tree
  • 21. C O M P O N E N T D ATA F L O W • Events flow up in tree
  • 22. T O O L I N G W H A T M A K E S R E A C T A W E S O M E
  • 23. E S 6 O R N O T E S 6 React encourages ES6
  • 24. E S 6 O R N O T E S 6 const makeCellTitle = (props) => { const { title, description } = props return `${title}: ${description}` } var title = 'Hello World' var description = 'A classic programmer thing' makeCellTitle({ title, description }) > Hello World: A classic programmer thing
  • 25. const makeCellTitle = (props) => { const { title, description } = props return `${title}: ${description}` } var title = 'Hello World' var description = 'A classic programmer thing' makeCellTitle({ title, description }) > Hello World: A classic programmer thing const makeCellTitle = (props) => { const { title, description } = props return `${title}: ${description}` } var title = 'Hello World' var description = 'A classic programmer thing' makeCellTitle({ title, description }) > Hello World: A classic programmer thing E S 6 O R N O T E S 6 A R R O W F U N C T I O N S
  • 26. const makeCellTitle = (props) => { const { title, description } = props return `${title}: ${description}` } var title = 'Hello World' var description = 'A classic programmer thing' makeCellTitle({ title, description }) > Hello World: A classic programmer thing const makeCellTitle = (props) => { const { title, description } = props return `${title}: ${description}` } var title = 'Hello World' var description = 'A classic programmer thing' makeCellTitle({ title, description }) > Hello World: A classic programmer thing E S 6 O R N O T E S 6 D E S T R U C T U R I N G
  • 27. E S 6 O R N O T E S 6 const makeCellTitle = (props) => { const { title, description } = props return `${title}: ${description}` } var title = 'Hello World' var description = 'A classic programmer thing' makeCellTitle({ title, description }) > Hello World: A classic programmer thing const makeCellTitle = (props) => { const { title, description } = props return `${title}: ${description}` } var title = 'Hello World' var description = 'A classic programmer thing' makeCellTitle({ title, description }) > Hello World: A classic programmer thing S T R I N G I N T E R P O L AT I O N
  • 28. const makeCellTitle = (props) => { const { title, description } = props return `${title}: ${description}` } var title = 'Hello World' var description = 'A classic programmer thing' makeCellTitle({ title, description }) > Hello World: A classic programmer thing E S 6 O R N O T E S 6 A R R O W F U N C T I O N S S T R I N G I N T E R P O L AT I O N D E S T R U C T U R I N G
  • 29. E S 6 O R N O T E S 6 • Native class syntax • Arrow functions • String interpolation • Destructuring • Code for the future const makeCellTitle = (props) => { const { title, description } = props return `${title}: ${description}` } var title = 'Hello World' var description = 'A classic programmer thing' makeCellTitle({ title, description }) > Hello World: A classic programmer thing A R R O W F U N C T I O N S S T R I N G I N T E R P O L AT I O N D E S T R U C T U R I N G
  • 30. J S X O R N O T J S X React encourages JSX
  • 31. J S X O R N O T J S X render() { return ( <div> <h1>A counter example</h1> <div>Current value is {this.state.counter}</div> <button onClick={this.handleButton.bind(this)}> Increase </button> </div> ) }
  • 32. render() { return ( <div> <h1>A counter example</h1> <div>Current value is {this.state.counter}</div> <button onClick={this.handleButton.bind(this)}> Increase </button> </div> ) } J S X O R N O T J S X • It's like HTML in side JavaScript • In reality it's just syntactic sugar • Transforms into plain JavaScript
  • 33. J S X O R N O T J S X render() { return React.createElement( 'div', null, React.createElement( 'h1', null, 'A counter example' ), React.createElement( 'div', null, 'Current value is ', this.state.counter ), React.createElement( 'button', { onClick: this.handleButton.bind(this) }, 'Increase' ) ) }
  • 34. J S X O R N O T J S X Use JSX, for the sake of sanity
  • 35. T R A N S F O R M I N G J S X • In-browser transform • More stuff to download • Slower due to compilation • Precompiled JS assets • Fast for the client • Integrated into build
  • 36. M A I N S T R E A M T O O L I N G • Babel • JavaScript Compiler • ES6 → ES5 • JSX → JavaScript
  • 37. M A I N S T R E A M T O O L I N G • Webpack • Module bundler • Join npm packages and your code • Apply loaders that transform files
  • 38. M A I N S T R E A M T O O L I N G J S X J S ( E S 5 ) babel-loader S C S S C S S postcss-loader P N G B A S E 6 4 file-loader B U N D L E . J S
  • 39. T O O L I N G The stack looks complicated
  • 40. T O O L I N G • Don't start with a boilerplate • github.com/gaearon/react-makes-you-sad
  • 41. D O N ' T S TA R T W I T H B O I L E R P L AT E
  • 42. T O O L I N G Understand the parts first
  • 43. D E M O T I M E S T E P B Y S T E P R E A C T P R O J E C T U S I N G B A B E L A N D W E B PA C K
  • 44. D E M O T I M E http://tiny.cc/react-beginners-demo
  • 45. R E F E R E N C E S • facebook.github.io/react/docs/component-api.html • facebook.github.io/react/docs/component-specs.html
  • 46. T H A N K S Q U E S T I O N S ?
  • 47. L I C E N S E • Copyright 2016 © Derek W. Stavis • Attribution-ShareAlike 4.0 International