Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Why React matters
Credits: lifehack.org
Why react matters
ShihChi
Huang
Why react matters
Why react matters
learn once
write anywhere
Why react matters
web developer
web developer
mobile developer
Why react matters
Why react matters
What’s React
A javascript
library for
building UI
A javascript
library for
building UI
javascript
A javascript
library for
building UI
javascript
UI
var Greeting = React.createClass({
render() {
return (
<p>{"HELLO " + this.props.name}</p>
);
}
});
<Greeting name="techplanet" />
// HELLO techplanet
Why react matters
against best practices
worst technology ever*
ridicolousback
90s
WTF
against best practices
worst technology ever*
ridicolousback
90s
WTF
Credits: vjeux@
min(Time to Find Root Cause)
M C
V
UNIX Philosophy
do one thing and do it well
UNIX Philosophy
do one thing and do it well
UNIX Philosophy
write programs to work together
do one thing and do it well
UNIX Philosophy
write programs to work together
handle text streams
Why react matters
Separation
of
Concerns
Why react matters
Why react matters
Why react matters
shouldComponentUpdate
shouldComponentUpdate
render
true
ES2015
warm-up
function hello() {
return 'world';
}
// arrow function
var hello = () => {
return 'world';
}
var hello = () => ‘world';
function hello() {
return 'world';
}
// arrow function
var hello = () => {
return 'world';
}
var hello = () => ‘world';
function hello() {
return 'world';
}
// arrow function
var hello = () => {
return 'world';
}
function hello() {
return 'world';
}
// arrow function
var hello = () => {
return 'world';
}
var hello = () => ‘world';
function hello() {
return 'world';
}
// arrow function
var hello = () => {
return 'world';
}
// arrow function
var hello = () => {
return 'world';
}
var hello = () => ‘world';
var state = {
foo: foo,
bar: bar,
}
var state = {
foo: foo,
bar: bar,
}
var state = {
foo: foo,
bar: bar,
}
// enhanced object literals
var state = {
};
var state = {
foo: foo,
bar: bar,
}
var state = {
foo: foo,
bar: bar,
}
// enhanced object literals
var state = {
};
var state = {
foo: foo,
bar: bar,
}
// enhanced object literals
var state = {
foo,
};
var state = {
foo: foo,
bar: bar,
}
var state = {
foo: foo,
bar: bar,
}
// enhanced object literals
var state = {
};
var state = {
foo: foo,
bar: bar,
}
// enhanced object literals
var state = {
foo,
};
var state = {
foo: foo,
bar: bar,
}
// enhanced object literals
var state = {
foo,
bar,
};
var Greet = React.createClass({
render() {
return <div />;
}
});
// class
class Greet extends React.Component {
render() {
return <div />;
}
}
var PropTypes = React.PropTypes;
var Components = React.Components;
// destructuring
var { PropTypes, Component } = React;
var PropTypes = React.PropTypes;
var Components = React.Components;
// destructuring
var { PropTypes, Component } = React;
var PropTypes = React.PropTypes;
var Components = React.Components;
// destructuring
var { PropTypes, Component } = React;
var PropTypes = React.PropTypes;
var Components = React.Components;
// destructuring
var { PropTypes, Component } = React;
var PropTypes = React.PropTypes;
var Components = React.Components;
// destructuring
var { PropTypes, Component } = React;
var PropTypes = React.PropTypes;
var Components = React.Components;
// destructuring
var { PropTypes, Component } = React;
var todos = this.props.todos.map(todo =>
<TodoItem
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
id={todo.id}
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
id={todo.id}
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
id={todo.id}
content={todo.content}
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
id={todo.id}
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
id={todo.id}
content={todo.content}
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
id={todo.id}
content={todo.content}
isCompleted={todo.isCompleted}
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
id={todo.id}
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
id={todo.id}
content={todo.content}
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
id={todo.id}
content={todo.content}
isCompleted={todo.isCompleted}
/>
});
var todos = this.props.todos.map(todo =>
<TodoItem
id={todo.id}
content={todo.content}
isCompleted={todo.isCompleted}
/>
});
// spread operator
var todos = this.props.todos.map(todo =>
<TodoItem {...todo} />
});
Why react matters
var data = {
foo: 'bar',
hello: 'world',
answer: 42,
};
var data = {
foo: 'bar',
hello: 'world',
answer: 42,
};
var { foo, ...rest } = data;
var data = {
foo: 'bar',
hello: 'world',
answer: 42,
};
var { foo, ...rest } = data;
// rest
{
hello: 'world',
answer: 42
}
// arrow function
var hello = () => ‘world’;
// enhanced object literal
var state = { foo, bar };
// destructuring
var { PropTypes, Component } = React;
// class
class Greet extends React.Component {}
// spread operator
<TodoItem {...todo} />
Are you still watchingthere?
Continue
Back
UI = f(state)
pure function
is a function where
the return value is only
determined by its input values
// f(x) = x + 1;
var increment = (x) => {
return x + 1;
}
// f(x) = 2^x * x^3 - x - 1;
var complex = (x) => {
return Math.pow(2, x)
* Math.pow(x, 3)
- x - 1;
}
pure function
is a function where
the return value is only
determined by its input values
at any given time
var counter = 0;
setInterval(() => counter++, 1000);
var timeVariant = (x) => {
return x + counter;
}
> timeVariant(3)
> 4
// after few seconds
> timeVariant(3)
> 7
Predictable
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
class TodoApp extends React.Component {
render() {
var { isLoaded, todos } = this.props;
if (!isLoaded) { return <Spinner />; }
if (!todos.length) {
return <EmptyResult />;
}
return (
<TodoList>
{this.props.todos.map(todo => {
return <TodoItem {...todo} />;
})}
</TodoList>
);
}
}
Why react matters
UX
Why react matters
simple ≠ familiar
credits: facebook.github.io/flux
scalable?
View
Store Dispatcher
Action
View
Store Dispatcher
Action
Unidirectional
Why react matters
re-render
whenever
state changes
re-render
whenever
state changes
re-render
whenever
state changes
computation
intensive?
Immutable!
get a new value
whenever make a change
credits: David Nolen
linked list
X
linked list
XY
linked list
XY
Z
linked list
XY
Z
structure sharing
linked list
structure sharing
structure sharing
• space efficiency
structure sharing
• computation efficiency
• space efficiency
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
return (
content !== nextProps.content &&
isCompleted !== nextProps.isCompleted
);
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
return (
content !== nextProps.content &&
isCompleted !== nextProps.isCompleted
);
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
return (
this.props === nextProps
);
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
return (
content !== nextProps.content &&
isCompleted !== nextProps.isCompleted
);
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
return (
this.props === nextProps
);
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
return (
content !== nextProps.content &&
isCompleted !== nextProps.isCompleted
);
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var { content, isCompleted } = this.props;
return (
this.props === nextProps
);
}
render() {
// ...
}
}
pros / nextProps are mutable and we
can’t simply
compare it’s reference
var Immutable = require('immutable');
var Immutable = require('immutable');var Immutable = require('immutable');
var todo = Immutable.Map({
content: 'say hello',
isCompleted: false
});
var Immutable = require('immutable');var Immutable = require('immutable');
var todo = Immutable.Map({
content: 'say hello',
isCompleted: false
});
var Immutable = require('immutable');
var todo = Immutable.Map({
content: 'say hello',
isCompleted: false
});
var mutatedTodo = todo.set(
“isCompleted”, true
);
var Immutable = require('immutable');var Immutable = require('immutable');
var todo = Immutable.Map({
content: 'say hello',
isCompleted: false
});
var Immutable = require('immutable');
var todo = Immutable.Map({
content: 'say hello',
isCompleted: false
});
var mutatedTodo = todo.set(
“isCompleted”, true
);
var Immutable = require('immutable');
var todo = Immutable.Map({
content: 'say hello',
isCompleted: false
});
var mutatedTodo = todo.set(
“isCompleted”, true
);
if (todo !== mutatedTodo) {
console.log('changed!');
// > changed!
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
return (
this.props === nextProps
);
}
render() {
// ...
}
}
class TodoItem extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
return (
this.props === nextProps
);
}
render() {
// ...
}
}
recap
recap
• UI = f(state)
recap
• Predictable
• UI = f(state)
recap
• Predictable
• UI = f(state)
• Immutable
<Questions />

More Related Content

What's hot

Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
Visual Engineering
 
Rxjs marble-testing
Rxjs marble-testingRxjs marble-testing
Rxjs marble-testing
Christoffer Noring
 
Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...
DroidConTLV
 
Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2
DreamLab
 
Sane Sharding with Akka Cluster
Sane Sharding with Akka ClusterSane Sharding with Akka Cluster
Sane Sharding with Akka Cluster
miciek
 
Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.
Astrails
 
Kotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere StockholmKotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere Stockholm
Fabio Collini
 
Kotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community confKotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community conf
Fabio Collini
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
David Gómez García
 
Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose world
Fabio Collini
 
Redux saga: managing your side effects. Also: generators in es6
Redux saga: managing your side effects. Also: generators in es6Redux saga: managing your side effects. Also: generators in es6
Redux saga: managing your side effects. Also: generators in es6
Ignacio Martín
 
What's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritageWhat's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritage
DroidConTLV
 
Managing parallelism using coroutines
Managing parallelism using coroutinesManaging parallelism using coroutines
Managing parallelism using coroutines
Fabio Collini
 
Kotlin Generation
Kotlin GenerationKotlin Generation
Kotlin Generation
Minseo Chayabanjonglerd
 
Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018
Konrad Malawski
 
Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3 Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3
DreamLab
 
Promise: async programming hero
Promise: async programming heroPromise: async programming hero
Promise: async programming hero
The Software House
 
The redux saga begins
The redux saga beginsThe redux saga begins
The redux saga begins
Daniel Franz
 
How do we use hooks
How do we use hooksHow do we use hooks
How do we use hooks
Jim Liu
 
Asynchronous CompletableFuture Presentation by László-Róbert Albert @Crossover
Asynchronous CompletableFuture Presentation by László-Róbert Albert @CrossoverAsynchronous CompletableFuture Presentation by László-Róbert Albert @Crossover
Asynchronous CompletableFuture Presentation by László-Róbert Albert @Crossover
Crossover Romania
 

What's hot (20)

Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
 
Rxjs marble-testing
Rxjs marble-testingRxjs marble-testing
Rxjs marble-testing
 
Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...Connecting your phone and home with firebase and android things - James Cogga...
Connecting your phone and home with firebase and android things - James Cogga...
 
Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2Quick start with React | DreamLab Academy #2
Quick start with React | DreamLab Academy #2
 
Sane Sharding with Akka Cluster
Sane Sharding with Akka ClusterSane Sharding with Akka Cluster
Sane Sharding with Akka Cluster
 
Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.
 
Kotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere StockholmKotlin delegates in practice - Kotlin Everywhere Stockholm
Kotlin delegates in practice - Kotlin Everywhere Stockholm
 
Kotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community confKotlin Delegates in practice - Kotlin community conf
Kotlin Delegates in practice - Kotlin community conf
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
 
Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose world
 
Redux saga: managing your side effects. Also: generators in es6
Redux saga: managing your side effects. Also: generators in es6Redux saga: managing your side effects. Also: generators in es6
Redux saga: managing your side effects. Also: generators in es6
 
What's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritageWhat's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritage
 
Managing parallelism using coroutines
Managing parallelism using coroutinesManaging parallelism using coroutines
Managing parallelism using coroutines
 
Kotlin Generation
Kotlin GenerationKotlin Generation
Kotlin Generation
 
Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018Akka Typed (quick talk) - JFokus 2018
Akka Typed (quick talk) - JFokus 2018
 
Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3 Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3
 
Promise: async programming hero
Promise: async programming heroPromise: async programming hero
Promise: async programming hero
 
The redux saga begins
The redux saga beginsThe redux saga begins
The redux saga begins
 
How do we use hooks
How do we use hooksHow do we use hooks
How do we use hooks
 
Asynchronous CompletableFuture Presentation by László-Róbert Albert @Crossover
Asynchronous CompletableFuture Presentation by László-Róbert Albert @CrossoverAsynchronous CompletableFuture Presentation by László-Róbert Albert @Crossover
Asynchronous CompletableFuture Presentation by László-Róbert Albert @Crossover
 

Viewers also liked

Introducing PostCSS
Introducing PostCSSIntroducing PostCSS
Introducing PostCSS
Rubén Crespo Álvarez
 
A month by month guide to On Hold Marketing for Restaurants and Hospitality.
A month by month guide to On Hold Marketing for Restaurants and Hospitality.A month by month guide to On Hold Marketing for Restaurants and Hospitality.
A month by month guide to On Hold Marketing for Restaurants and Hospitality.
Advitel_crow_greencm15
 
Linux 教育訓練
Linux 教育訓練Linux 教育訓練
Linux 教育訓練
Bo-Yi Wu
 
Google blogger 教學
Google blogger 教學Google blogger 教學
Google blogger 教學
鈺棠 徐
 
CSS入門教學
CSS入門教學CSS入門教學
CSS入門教學
鈺棠 徐
 
jQuery入門
jQuery入門jQuery入門
jQuery入門
鈺棠 徐
 
Passing The Joel Test In The PHP World
Passing The Joel Test In The PHP WorldPassing The Joel Test In The PHP World
Passing The Joel Test In The PHP World
Lorna Mitchell
 
PHPUnit best practices presentation
PHPUnit best practices presentationPHPUnit best practices presentation
PHPUnit best practices presentation
Thanh Robi
 
The road to php 7.1
The road to php 7.1The road to php 7.1
The road to php 7.1
Michelangelo van Dam
 
JavaScript/CSS 2015 Autumn
JavaScript/CSS 2015 AutumnJavaScript/CSS 2015 Autumn
JavaScript/CSS 2015 Autumn
Koji Ishimoto
 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday Developer
Ross Tuck
 
Redis in Practice
Redis in PracticeRedis in Practice
Redis in Practice
Noah Davis
 

Viewers also liked (12)

Introducing PostCSS
Introducing PostCSSIntroducing PostCSS
Introducing PostCSS
 
A month by month guide to On Hold Marketing for Restaurants and Hospitality.
A month by month guide to On Hold Marketing for Restaurants and Hospitality.A month by month guide to On Hold Marketing for Restaurants and Hospitality.
A month by month guide to On Hold Marketing for Restaurants and Hospitality.
 
Linux 教育訓練
Linux 教育訓練Linux 教育訓練
Linux 教育訓練
 
Google blogger 教學
Google blogger 教學Google blogger 教學
Google blogger 教學
 
CSS入門教學
CSS入門教學CSS入門教學
CSS入門教學
 
jQuery入門
jQuery入門jQuery入門
jQuery入門
 
Passing The Joel Test In The PHP World
Passing The Joel Test In The PHP WorldPassing The Joel Test In The PHP World
Passing The Joel Test In The PHP World
 
PHPUnit best practices presentation
PHPUnit best practices presentationPHPUnit best practices presentation
PHPUnit best practices presentation
 
The road to php 7.1
The road to php 7.1The road to php 7.1
The road to php 7.1
 
JavaScript/CSS 2015 Autumn
JavaScript/CSS 2015 AutumnJavaScript/CSS 2015 Autumn
JavaScript/CSS 2015 Autumn
 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday Developer
 
Redis in Practice
Redis in PracticeRedis in Practice
Redis in Practice
 

Similar to Why react matters

Higher Order Components and Render Props
Higher Order Components and Render PropsHigher Order Components and Render Props
Higher Order Components and Render Props
Nitish Phanse
 
Recompacting your react application
Recompacting your react applicationRecompacting your react application
Recompacting your react application
Greg Bergé
 
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JSFestUA
 
React redux
React reduxReact redux
React redux
Michel Perez
 
25-functions.ppt
25-functions.ppt25-functions.ppt
25-functions.ppt
JyothiAmpally
 
Higher-Order Components — Ilya Gelman
Higher-Order Components — Ilya GelmanHigher-Order Components — Ilya Gelman
Higher-Order Components — Ilya Gelman
500Tech
 
React JS Hooks Sheet .pdf
React JS Hooks Sheet .pdfReact JS Hooks Sheet .pdf
React JS Hooks Sheet .pdf
nishant078cs23
 
2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & Webpack2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & Webpack
Codifly
 
Learning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User InterfacesLearning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User Interfaces
Ken Wheeler
 
React 101
React 101React 101
React 101
Casear Chu
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7
Dongho Cho
 
Chaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreChaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscore
Nicolas Carlo
 
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
Joachim Bengtsson
 
JSConf: All You Can Leet
JSConf: All You Can LeetJSConf: All You Can Leet
JSConf: All You Can Leet
johndaviddalton
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Codemotion
 
Egghead redux-cheat-sheet-3-2-1
Egghead redux-cheat-sheet-3-2-1Egghead redux-cheat-sheet-3-2-1
Egghead redux-cheat-sheet-3-2-1
Augustin Bralley
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
 
Kitura Todolist tutorial
Kitura Todolist tutorialKitura Todolist tutorial
Kitura Todolist tutorial
Robert F. Dickerson
 
Reactивная тяга
Reactивная тягаReactивная тяга
Reactивная тяга
Vitebsk Miniq
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgets
velveeta_512
 

Similar to Why react matters (20)

Higher Order Components and Render Props
Higher Order Components and Render PropsHigher Order Components and Render Props
Higher Order Components and Render Props
 
Recompacting your react application
Recompacting your react applicationRecompacting your react application
Recompacting your react application
 
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
 
React redux
React reduxReact redux
React redux
 
25-functions.ppt
25-functions.ppt25-functions.ppt
25-functions.ppt
 
Higher-Order Components — Ilya Gelman
Higher-Order Components — Ilya GelmanHigher-Order Components — Ilya Gelman
Higher-Order Components — Ilya Gelman
 
React JS Hooks Sheet .pdf
React JS Hooks Sheet .pdfReact JS Hooks Sheet .pdf
React JS Hooks Sheet .pdf
 
2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & Webpack2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & Webpack
 
Learning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User InterfacesLearning React: Facebook's Javascript Library For Building User Interfaces
Learning React: Facebook's Javascript Library For Building User Interfaces
 
React 101
React 101React 101
React 101
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7
 
Chaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscoreChaining and function composition with lodash / underscore
Chaining and function composition with lodash / underscore
 
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
Nevyn — Promise, It's Async! Swift Language User Group Lightning Talk 2015-09-24
 
JSConf: All You Can Leet
JSConf: All You Can LeetJSConf: All You Can Leet
JSConf: All You Can Leet
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
 
Egghead redux-cheat-sheet-3-2-1
Egghead redux-cheat-sheet-3-2-1Egghead redux-cheat-sheet-3-2-1
Egghead redux-cheat-sheet-3-2-1
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Kitura Todolist tutorial
Kitura Todolist tutorialKitura Todolist tutorial
Kitura Todolist tutorial
 
Reactивная тяга
Reactивная тягаReactивная тяга
Reactивная тяга
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgets
 

Recently uploaded

Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
Ortus Solutions, Corp
 
AI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdfAI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdf
ayushiqss
 
Design system: The basis for a consistent design
Design system: The basis for a consistent designDesign system: The basis for a consistent design
Design system: The basis for a consistent design
Ortus Solutions, Corp
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
sachin chaurasia
 
Web Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox ProWeb Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox Pro
Ortus Solutions, Corp
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
avufu
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Estuary Flow
 
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
Ortus Solutions, Corp
 
What is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for FreeWhat is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for Free
TwisterTools
 
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Misti Soneji
 
Mumbai @Call @Girls Whatsapp 9930687706 With High Profile Service
Mumbai @Call @Girls Whatsapp 9930687706 With High Profile ServiceMumbai @Call @Girls Whatsapp 9930687706 With High Profile Service
Mumbai @Call @Girls Whatsapp 9930687706 With High Profile Service
kolkata dolls
 
Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01
williamrobertherman
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
 @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ... @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
Mona Rathore
 
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
 @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S... @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
Mona Rathore
 
Securing Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecuritySecuring Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecurity
Ortus Solutions, Corp
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
MaisnamLuwangPibarel
 
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdfWhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
onemonitarsoftware
 
Non-Functional Testing Guide_ Exploring Its Types, Importance and Tools.pdf
Non-Functional Testing Guide_ Exploring Its Types, Importance and Tools.pdfNon-Functional Testing Guide_ Exploring Its Types, Importance and Tools.pdf
Non-Functional Testing Guide_ Exploring Its Types, Importance and Tools.pdf
kalichargn70th171
 
BoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and DebuggerBoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and Debugger
Ortus Solutions, Corp
 

Recently uploaded (20)

Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
 
AI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdfAI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdf
 
Design system: The basis for a consistent design
Design system: The basis for a consistent designDesign system: The basis for a consistent design
Design system: The basis for a consistent design
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
 
Web Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox ProWeb Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox Pro
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
 
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
 
What is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for FreeWhat is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for Free
 
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
 
Mumbai @Call @Girls Whatsapp 9930687706 With High Profile Service
Mumbai @Call @Girls Whatsapp 9930687706 With High Profile ServiceMumbai @Call @Girls Whatsapp 9930687706 With High Profile Service
Mumbai @Call @Girls Whatsapp 9930687706 With High Profile Service
 
Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
 @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ... @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
 
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
 @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S... @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
 
Securing Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecuritySecuring Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecurity
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
 
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdfWhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
 
Non-Functional Testing Guide_ Exploring Its Types, Importance and Tools.pdf
Non-Functional Testing Guide_ Exploring Its Types, Importance and Tools.pdfNon-Functional Testing Guide_ Exploring Its Types, Importance and Tools.pdf
Non-Functional Testing Guide_ Exploring Its Types, Importance and Tools.pdf
 
BoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and DebuggerBoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and Debugger
 

Why react matters

  • 17. var Greeting = React.createClass({ render() { return ( <p>{"HELLO " + this.props.name}</p> ); } }); <Greeting name="techplanet" /> // HELLO techplanet
  • 19. against best practices worst technology ever* ridicolousback 90s WTF
  • 20. against best practices worst technology ever* ridicolousback 90s WTF
  • 21. Credits: vjeux@ min(Time to Find Root Cause)
  • 22. M C V
  • 24. do one thing and do it well UNIX Philosophy
  • 25. do one thing and do it well UNIX Philosophy write programs to work together
  • 26. do one thing and do it well UNIX Philosophy write programs to work together handle text streams
  • 35. function hello() { return 'world'; } // arrow function var hello = () => { return 'world'; } var hello = () => ‘world';
  • 36. function hello() { return 'world'; } // arrow function var hello = () => { return 'world'; } var hello = () => ‘world'; function hello() { return 'world'; } // arrow function var hello = () => { return 'world'; }
  • 37. function hello() { return 'world'; } // arrow function var hello = () => { return 'world'; } var hello = () => ‘world'; function hello() { return 'world'; } // arrow function var hello = () => { return 'world'; } // arrow function var hello = () => { return 'world'; } var hello = () => ‘world';
  • 38. var state = { foo: foo, bar: bar, }
  • 39. var state = { foo: foo, bar: bar, } var state = { foo: foo, bar: bar, } // enhanced object literals var state = { };
  • 40. var state = { foo: foo, bar: bar, } var state = { foo: foo, bar: bar, } // enhanced object literals var state = { }; var state = { foo: foo, bar: bar, } // enhanced object literals var state = { foo, };
  • 41. var state = { foo: foo, bar: bar, } var state = { foo: foo, bar: bar, } // enhanced object literals var state = { }; var state = { foo: foo, bar: bar, } // enhanced object literals var state = { foo, }; var state = { foo: foo, bar: bar, } // enhanced object literals var state = { foo, bar, };
  • 42. var Greet = React.createClass({ render() { return <div />; } }); // class class Greet extends React.Component { render() { return <div />; } }
  • 43. var PropTypes = React.PropTypes; var Components = React.Components; // destructuring var { PropTypes, Component } = React;
  • 44. var PropTypes = React.PropTypes; var Components = React.Components; // destructuring var { PropTypes, Component } = React; var PropTypes = React.PropTypes; var Components = React.Components; // destructuring var { PropTypes, Component } = React;
  • 45. var PropTypes = React.PropTypes; var Components = React.Components; // destructuring var { PropTypes, Component } = React; var PropTypes = React.PropTypes; var Components = React.Components; // destructuring var { PropTypes, Component } = React; var PropTypes = React.PropTypes; var Components = React.Components; // destructuring var { PropTypes, Component } = React;
  • 46. var todos = this.props.todos.map(todo => <TodoItem /> });
  • 47. var todos = this.props.todos.map(todo => <TodoItem /> }); var todos = this.props.todos.map(todo => <TodoItem id={todo.id} /> });
  • 48. var todos = this.props.todos.map(todo => <TodoItem /> }); var todos = this.props.todos.map(todo => <TodoItem id={todo.id} /> }); var todos = this.props.todos.map(todo => <TodoItem id={todo.id} content={todo.content} /> });
  • 49. var todos = this.props.todos.map(todo => <TodoItem /> }); var todos = this.props.todos.map(todo => <TodoItem id={todo.id} /> }); var todos = this.props.todos.map(todo => <TodoItem id={todo.id} content={todo.content} /> }); var todos = this.props.todos.map(todo => <TodoItem id={todo.id} content={todo.content} isCompleted={todo.isCompleted} /> });
  • 50. var todos = this.props.todos.map(todo => <TodoItem /> }); var todos = this.props.todos.map(todo => <TodoItem id={todo.id} /> }); var todos = this.props.todos.map(todo => <TodoItem id={todo.id} content={todo.content} /> }); var todos = this.props.todos.map(todo => <TodoItem id={todo.id} content={todo.content} isCompleted={todo.isCompleted} /> }); var todos = this.props.todos.map(todo => <TodoItem id={todo.id} content={todo.content} isCompleted={todo.isCompleted} /> }); // spread operator var todos = this.props.todos.map(todo => <TodoItem {...todo} /> });
  • 52. var data = { foo: 'bar', hello: 'world', answer: 42, };
  • 53. var data = { foo: 'bar', hello: 'world', answer: 42, }; var { foo, ...rest } = data;
  • 54. var data = { foo: 'bar', hello: 'world', answer: 42, }; var { foo, ...rest } = data; // rest { hello: 'world', answer: 42 }
  • 55. // arrow function var hello = () => ‘world’; // enhanced object literal var state = { foo, bar }; // destructuring var { PropTypes, Component } = React; // class class Greet extends React.Component {} // spread operator <TodoItem {...todo} />
  • 56. Are you still watchingthere? Continue Back
  • 58. pure function is a function where the return value is only determined by its input values
  • 59. // f(x) = x + 1; var increment = (x) => { return x + 1; } // f(x) = 2^x * x^3 - x - 1; var complex = (x) => { return Math.pow(2, x) * Math.pow(x, 3) - x - 1; }
  • 60. pure function is a function where the return value is only determined by its input values at any given time
  • 61. var counter = 0; setInterval(() => counter++, 1000); var timeVariant = (x) => { return x + counter; } > timeVariant(3) > 4 // after few seconds > timeVariant(3) > 7
  • 63. class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } }
  • 64. class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } } class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } }
  • 65. class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } } class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } } class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } }
  • 66. class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } } class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } } class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } } class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } }
  • 67. class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } } class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } } class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } } class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } } class TodoApp extends React.Component { render() { var { isLoaded, todos } = this.props; if (!isLoaded) { return <Spinner />; } if (!todos.length) { return <EmptyResult />; } return ( <TodoList> {this.props.todos.map(todo => { return <TodoItem {...todo} />; })} </TodoList> ); } }
  • 69. UX
  • 82. get a new value whenever make a change
  • 91. structure sharing • computation efficiency • space efficiency
  • 92. class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { } render() { // ... } }
  • 93. class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; } render() { // ... } }
  • 94. class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; return ( content !== nextProps.content && isCompleted !== nextProps.isCompleted ); } render() { // ... } }
  • 95. class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; return ( content !== nextProps.content && isCompleted !== nextProps.isCompleted ); } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; return ( this.props === nextProps ); } render() { // ... } }
  • 96. class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; return ( content !== nextProps.content && isCompleted !== nextProps.isCompleted ); } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; return ( this.props === nextProps ); } render() { // ... } }
  • 97. class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; return ( content !== nextProps.content && isCompleted !== nextProps.isCompleted ); } render() { // ... } } class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { var { content, isCompleted } = this.props; return ( this.props === nextProps ); } render() { // ... } } pros / nextProps are mutable and we can’t simply compare it’s reference
  • 98. var Immutable = require('immutable');
  • 99. var Immutable = require('immutable');var Immutable = require('immutable'); var todo = Immutable.Map({ content: 'say hello', isCompleted: false });
  • 100. var Immutable = require('immutable');var Immutable = require('immutable'); var todo = Immutable.Map({ content: 'say hello', isCompleted: false }); var Immutable = require('immutable'); var todo = Immutable.Map({ content: 'say hello', isCompleted: false }); var mutatedTodo = todo.set( “isCompleted”, true );
  • 101. var Immutable = require('immutable');var Immutable = require('immutable'); var todo = Immutable.Map({ content: 'say hello', isCompleted: false }); var Immutable = require('immutable'); var todo = Immutable.Map({ content: 'say hello', isCompleted: false }); var mutatedTodo = todo.set( “isCompleted”, true ); var Immutable = require('immutable'); var todo = Immutable.Map({ content: 'say hello', isCompleted: false }); var mutatedTodo = todo.set( “isCompleted”, true ); if (todo !== mutatedTodo) { console.log('changed!'); // > changed! }
  • 102. class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { return ( this.props === nextProps ); } render() { // ... } }
  • 103. class TodoItem extends React.Component { shouldComponentUpdate(nextProps, nextState) { return ( this.props === nextProps ); } render() { // ... } }
  • 104. recap
  • 105. recap • UI = f(state)
  • 107. recap • Predictable • UI = f(state) • Immutable