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

React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
valuebound
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
DivyanshGupta922023
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
Bethmi Gunasekara
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
Knoldus Inc.
 
React js
React jsReact js
React js
Rajesh Kolla
 
Redux workshop
Redux workshopRedux workshop
Redux workshop
Imran Sayed
 
Reactjs
ReactjsReactjs
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
Varun Raj
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
Samundra khatri
 
Intro to React
Intro to ReactIntro to React
Intro to React
Justin Reock
 
React hooks
React hooksReact hooks
React hooks
Ramy ElBasyouni
 
React Hooks
React HooksReact Hooks
React Hooks
Erez Cohen
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
Alessandro Valenti
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
Rob Quick
 
React JS
React JSReact JS
ReactJS
ReactJSReactJS
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
MicroPyramid .
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
Doug Neiner
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
Ritesh Mehrotra
 
React/Redux
React/ReduxReact/Redux
React/Redux
Durgesh Vaishnav
 

What's hot (20)

React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
React js
React jsReact js
React js
 
Redux workshop
Redux workshopRedux workshop
Redux workshop
 
Reactjs
ReactjsReactjs
Reactjs
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
React hooks
React hooksReact hooks
React hooks
 
React Hooks
React HooksReact Hooks
React Hooks
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
 
React JS
React JSReact JS
React JS
 
ReactJS
ReactJSReactJS
ReactJS
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
React/Redux
React/ReduxReact/Redux
React/Redux
 

Viewers also liked

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

Viewers also liked (6)

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

Similar to React for Beginners

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

Similar to React for Beginners (20)

An Introduction to React -- FED Date -- IBM Design
An Introduction to React -- FED Date -- IBM DesignAn Introduction to React -- FED Date -- IBM Design
An Introduction to React -- FED Date -- IBM Design
 
PostgreSQL Open SV 2018
PostgreSQL Open SV 2018PostgreSQL Open SV 2018
PostgreSQL Open SV 2018
 
Дмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI векеДмитрий Нестерук, Паттерны проектирования в XXI веке
Дмитрий Нестерук, Паттерны проектирования в XXI веке
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...
 
Xephon K A Time series database with multiple backends
Xephon K A Time series database with multiple backendsXephon K A Time series database with multiple backends
Xephon K A Time series database with multiple backends
 
Design Patterns in Modern C++
Design Patterns in Modern C++Design Patterns in Modern C++
Design Patterns in Modern C++
 
Jsonsaga 100605143125-phpapp02
Jsonsaga 100605143125-phpapp02Jsonsaga 100605143125-phpapp02
Jsonsaga 100605143125-phpapp02
 
Slides
SlidesSlides
Slides
 
WordPress for the 99%
WordPress for the 99%WordPress for the 99%
WordPress for the 99%
 
Building and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning CBuilding and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning C
 
Why you should be using the shiny new C# 6.0 features now!
Why you should be using the shiny new C# 6.0 features now!Why you should be using the shiny new C# 6.0 features now!
Why you should be using the shiny new C# 6.0 features now!
 
Connect2016 AD1387 Integrate with XPages and Java
Connect2016 AD1387 Integrate with XPages and JavaConnect2016 AD1387 Integrate with XPages and Java
Connect2016 AD1387 Integrate with XPages and Java
 
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...
AD1387: Outside The Box: Integrating with Non-Domino Apps using XPages and Ja...
 
Java script
Java scriptJava script
Java script
 
Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21
 
New Android Languages
New Android LanguagesNew Android Languages
New Android Languages
 
ReactDC Intro to NextJS 9
ReactDC Intro to NextJS 9ReactDC Intro to NextJS 9
ReactDC Intro to NextJS 9
 
JavaScript Abstraction
JavaScript AbstractionJavaScript Abstraction
JavaScript Abstraction
 
Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 

More from Derek Willian Stavis

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

More from Derek Willian Stavis (7)

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

Recently uploaded

top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 

Recently uploaded (20)

top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 

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