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

What's hot (20)

PDF
Vue, vue router, vuex
Samundra khatri
 
PDF
ReactJS presentation
Thanh Tuong
 
PPTX
The Benefits of Using React JS for Web Development!
Baharika Sopori
 
PPTX
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
PPTX
Its time to React.js
Ritesh Mehrotra
 
PDF
Workshop React.js
Commit University
 
PPTX
Introduction to react_js
MicroPyramid .
 
PPT
React js
Jai Santhosh
 
PPTX
Introduction to React
Rob Quick
 
PPTX
Intro to React
Justin Reock
 
PDF
The Point of Vue - Intro to Vue.js
Holly Schinsky
 
PDF
Getting started with Next.js
Gökhan Sarı
 
PPTX
ReactJs
Sahana Banerjee
 
PDF
Next.js Introduction
Saray Chak
 
PDF
An introduction to React.js
Emanuele DelBono
 
PDF
Intro to vue.js
TechMagic
 
PPTX
[Final] ReactJS presentation
洪 鹏发
 
PPTX
Intro to React
Eric Westfall
 
ODP
Introduction to ReactJS
Knoldus Inc.
 
PPT
Spring ppt
Mumbai Academisc
 
Vue, vue router, vuex
Samundra khatri
 
ReactJS presentation
Thanh Tuong
 
The Benefits of Using React JS for Web Development!
Baharika Sopori
 
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
Its time to React.js
Ritesh Mehrotra
 
Workshop React.js
Commit University
 
Introduction to react_js
MicroPyramid .
 
React js
Jai Santhosh
 
Introduction to React
Rob Quick
 
Intro to React
Justin Reock
 
The Point of Vue - Intro to Vue.js
Holly Schinsky
 
Getting started with Next.js
Gökhan Sarı
 
Next.js Introduction
Saray Chak
 
An introduction to React.js
Emanuele DelBono
 
Intro to vue.js
TechMagic
 
[Final] ReactJS presentation
洪 鹏发
 
Intro to React
Eric Westfall
 
Introduction to ReactJS
Knoldus Inc.
 
Spring ppt
Mumbai Academisc
 

Viewers also liked (6)

PDF
Introduction to node.js, npm and grunt
Jaecheol Lee
 
PDF
Jaap : node, npm & grunt
Bertrand Chevrier
 
PPTX
Front end task automation using grunt, yeoman and npm(1)
Frank Marcelo
 
PDF
Workshop 3: JavaScript build tools
Visual Engineering
 
PPTX
Building modern share point apps (angularjs, npm, bower, grunt, VS2015)
Sergei Sergeev
 
PDF
Forget Grunt and Gulp! Webpack and NPM rule them all!
Derek Willian Stavis
 
Introduction to node.js, npm and grunt
Jaecheol Lee
 
Jaap : node, npm & grunt
Bertrand Chevrier
 
Front end task automation using grunt, yeoman and npm(1)
Frank Marcelo
 
Workshop 3: JavaScript build tools
Visual Engineering
 
Building modern share point apps (angularjs, npm, bower, grunt, VS2015)
Sergei Sergeev
 
Forget Grunt and Gulp! Webpack and NPM rule them all!
Derek Willian Stavis
 
Ad

Similar to React for Beginners (20)

PDF
An Introduction to React -- FED Date -- IBM Design
Josh Black
 
PDF
PostgreSQL Open SV 2018
artgillespie
 
PPTX
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Sergey Platonov
 
PDF
Asynchronous single page applications without a line of HTML or Javascript, o...
Robert Schadek
 
PDF
Xephon K A Time series database with multiple backends
University of California, Santa Cruz
 
PDF
Design Patterns in Modern C++
Dmitri Nesteruk
 
PDF
Jsonsaga 100605143125-phpapp02
Ramamohan Chokkam
 
PPTX
Slides
shahriar-ro
 
PPTX
WordPress for the 99%
Stephanie Leary
 
KEY
Building and Distributing PostgreSQL Extensions Without Learning C
David Wheeler
 
PPTX
Why you should be using the shiny new C# 6.0 features now!
Eric Phan
 
PDF
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...
panagenda
 
PDF
Connect2016 AD1387 Integrate with XPages and Java
Julian Robichaux
 
PPT
Java script
vishal choudhary
 
PDF
Apache Calcite Tutorial - BOSS 21
Stamatis Zampetakis
 
PDF
New Android Languages
Javier Gamarra
 
PDF
ReactDC Intro to NextJS 9
Allison Kunz
 
PDF
JavaScript Abstraction
☆ Milan Adamovsky ☆
 
PDF
Dependency Injection: Why is awesome and why should I care?
devObjective
 
PDF
Dependency Injection
ColdFusionConference
 
An Introduction to React -- FED Date -- IBM Design
Josh Black
 
PostgreSQL Open SV 2018
artgillespie
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Sergey Platonov
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Robert Schadek
 
Xephon K A Time series database with multiple backends
University of California, Santa Cruz
 
Design Patterns in Modern C++
Dmitri Nesteruk
 
Jsonsaga 100605143125-phpapp02
Ramamohan Chokkam
 
Slides
shahriar-ro
 
WordPress for the 99%
Stephanie Leary
 
Building and Distributing PostgreSQL Extensions Without Learning C
David Wheeler
 
Why you should be using the shiny new C# 6.0 features now!
Eric Phan
 
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...
panagenda
 
Connect2016 AD1387 Integrate with XPages and Java
Julian Robichaux
 
Java script
vishal choudhary
 
Apache Calcite Tutorial - BOSS 21
Stamatis Zampetakis
 
New Android Languages
Javier Gamarra
 
ReactDC Intro to NextJS 9
Allison Kunz
 
JavaScript Abstraction
☆ Milan Adamovsky ☆
 
Dependency Injection: Why is awesome and why should I care?
devObjective
 
Dependency Injection
ColdFusionConference
 
Ad

More from Derek Willian Stavis (7)

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

Recently uploaded (20)

PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 

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