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
An introduction to React.js
Emanuele DelBono
 
PDF
Introduction to Node.js
Rob O'Doherty
 
PPTX
React workshop presentation
Bojan Golubović
 
PPTX
React workshop
Imran Sayed
 
PPTX
Introduction to React JS for beginners | Namespace IT
namespaceit
 
PPTX
Introduction to React JS for beginners
Varun Raj
 
PPTX
ReactJs
Sahana Banerjee
 
PDF
React js
Rajesh Kolla
 
PPTX
React web development
Rully Ramanda
 
PPTX
Getting started with Redux js
Citrix
 
PPTX
React js for beginners
Alessandro Valenti
 
PDF
React JS - Introduction
Sergey Romaneko
 
PPTX
reactJS
Syam Santhosh
 
PPTX
React JS part 1
Diluka Wittahachchige
 
PDF
ReactJS
Hiten Pratap Singh
 
PDF
Introduction to Redux
Ignacio Martín
 
PPTX
React js basics
Maulik Shah
 
PDF
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Edureka!
 
PPTX
React JS: A Secret Preview
valuebound
 
An introduction to React.js
Emanuele DelBono
 
Introduction to Node.js
Rob O'Doherty
 
React workshop presentation
Bojan Golubović
 
React workshop
Imran Sayed
 
Introduction to React JS for beginners | Namespace IT
namespaceit
 
Introduction to React JS for beginners
Varun Raj
 
React js
Rajesh Kolla
 
React web development
Rully Ramanda
 
Getting started with Redux js
Citrix
 
React js for beginners
Alessandro Valenti
 
React JS - Introduction
Sergey Romaneko
 
reactJS
Syam Santhosh
 
React JS part 1
Diluka Wittahachchige
 
Introduction to Redux
Ignacio Martín
 
React js basics
Maulik Shah
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Edureka!
 
React JS: A Secret Preview
valuebound
 

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)

PDF
Troubleshooting Virtual Threads in Java!
Tier1 app
 
PDF
AI Software Engineering based on Multi-view Modeling and Engineering Patterns
Hironori Washizaki
 
PPTX
Chess King 25.0.0.2500 With Crack Full Free Download
cracked shares
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PDF
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PDF
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
PDF
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
PDF
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
PDF
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
PDF
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PDF
SAP GUI Installation Guide for Windows | Step-by-Step Setup for SAP Access
SAP Vista, an A L T Z E N Company
 
PPTX
TexSender Pro 8.9.1 Crack Full Version Download
cracked shares
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
Troubleshooting Virtual Threads in Java!
Tier1 app
 
AI Software Engineering based on Multi-view Modeling and Engineering Patterns
Hironori Washizaki
 
Chess King 25.0.0.2500 With Crack Full Free Download
cracked shares
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
 
Activate_Methodology_Summary presentatio
annapureddyn
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
SAP GUI Installation Guide for Windows | Step-by-Step Setup for SAP Access
SAP Vista, an A L T Z E N Company
 
TexSender Pro 8.9.1 Crack Full Version Download
cracked shares
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 

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