11111011111
≈ 1 second compile time
A better way to do data fetching for complex applications.
How we usually do it now:
Server
...........................................................................
<friendList>
<friendListItem>
<friendInfo>
There are [at least] two problems with this way of doing it;
Facebook has a different approach
Facebook has a different approach
var FriendsInfo = React.createClass({
statics: {
user: function() {
return graphql`
User {
name,
mutual_friends { count }
}
`;
}
},
render: function() {
return (
<div>
<span>{this.props.user.name}</span>
<span>{this.props.user.mutual_friends.count} mutual friends</span>
</div>
);
}
});
GraphQL is a data querying language designed to describe the complex, nested data dependencies of modern applications.
var immutable = require('immutable'),
var list1 = immutable.List.of(1, 2, 3);
var list2 = list1.push(4);
list1 === list2; // false
var immutable = require('immutable'),
var map1 = immutable.Map({
a: 1,
b: 2,
c: 3
});
var map2 = map1.set('c', 3);
assert(map1 === map2); // true
var map3 = map1.set('c', 50);
assert(map1 === map3); // false
With React, immutable data is awesome
PureRenderMixin + Immutable.js == Fast
(shouldComponentUpdate? Simple)
Some things to note:
...is just one approach to immutability:
Simple internationalization and formatting
The Intl APIs are currently available on all modern browsers except Safari. It is not available on mobile browsers, older browsers, or Node.js. Polyfill for Intl exists and should be used for cases where Intl is missing.
7.7kb (min + gz)
150+ languages
Date and number formatting
<FormattedNumber value={1000} />
<FormattedDate value={Date.now()}
month="long"
day="numeric"
year="numeric" />
<FormattedRelative value={this.props.date} />
# 3 hours agoString messages and pluralization
var msg = `{numComments, plural,
one { # comment }
other { # comments }
}`;
<FormattedMessage message={msg} numComments={1} />
# 1 comment
<FormattedMessage message={msg} numComments={2} />
# 12,345 comments
Note: ES6 multiline strings for slide readability
var App = React.createClass({
mixins: [IntlMixin],
render: function() {
return <FormattedNumber value={this.props.price}
style="currency"
currency="USD" />
}
});
React.render(
<App locales="fr-FR" price={1999.95} />,
document.getElementById('container')
);
# Renders:
1 999,95 $USWebpack + React =
Awesome
Demo?
# sum.js
/* @flow */
function sum (a: number, b: number) {
return a + b;
}
sum("1", 2);
$ flow
hello.js:7:5,7: string
This type is incompatible with
[...]/sum.js:3:17,22: numberIn this example, flow detects that one of the values is not a number.
/* @flow */
function total(numbers: Array<number>) {
var result = 0;
for (var i = 0; i < numbers.length; i++) {
result += numbers[i];
}
return result;
}
total([1, 2, 3, 'Hello']);
$ flow
arrays.js:11:17,23: string
This type is incompatible with
/arrays.js:3:31,36: numberBeyond the DOM
Four basic keywords:
CHAN
creates a channel
CHAN
puts a value
TAKE
takes a value
GO
starts a process
let { chan, go, take, put } = require('js-csp');
let ch = chan();
go(function*() {
while(true) {
console.log(yield take(ch));
}
});
go(function*() {
yield put(1);
yield put(2);
yield put(3);
});
// Output: 1 2 3Take/put is blocking by design, so when a value is put execution will wait for a take before continuing. Because of this, we know that when an event has gone through our system, the two parts are at the same state.
Our packagers use machine learning [...] we log CDN traffic and once a week we process the data and figure out what next weeks site is very likely to need based on that.
- Tom Occhino, ReactJS team @ Facebook
ES6 is being embraced by React
Welcoming, awesome conference
Awesome venue
Great organizing, packed schedule
Great food!
Nice weather!
Epic work environment
Facebook cares about their employees
California has some awesome beer :-)
Great conference, would go again.