N I KO L AY B A C H I Y S K I , A U TO M AT T I C , W O R D C A M P H E L S I N K I , A P R I L 1 6 , 2 0 1 6
View Slide
A U TO M AT T I C
A U TO M AT T I CE X T R A P O L AT E . M E
A U TO M AT T I CE X T R A P O L AT E . M E@ N I KO L AY B
R E S T A P I
R E S T A P ICALYPSO
R E S T A P I ↓ S I N G L E - PA G E A P P S
W H Y ?
FA S T E R
M O R EE N G A G I N G
C H A N G EL E T ' S TA L K A B O U T
S TAT EL E T ' S TA L K A B O U T
C L A S S I CV S .S I N G L E - PA G E A P P S
C L A S S I C
C H A N G E 㱺 R E F R E S HC L A S S I C
C H A N G E 㱺S I N G L E - PA G E
U I L I B R A RY
N OT A F R A M E W O R K
const Post = React.createClass( {render() {return ({ this.props.post.content });}} );
const Post = React.createClass( {render() {return ({ this.props.post.content });}} );J SX
const Post = React.createClass( {function render() {return (React.DOM.div({className: 'post'},[ React.DOM.p(null,this.props.post.content),PostMeta( {post: this.props.post} )););}} );
const PostMeta = React.createClass( {…} );
const PostMeta = React.createClass( {getInitialState() {return { hidden: true };},onToggle() {this.setState( { hidden: ! this.state.hidden } );},render() {return ({ this.props.post.author }{ this.state.hidden ? 'More' : 'Hide' }( this.state.hidden ?…extra meta… :null));}} );
const PostMeta = React.createClass( {getInitialState() {return { hidden: true };},onToggle() {this.setState( { hidden: ! this.state.hidden } );},render() {return ({ this.props.post.author }{ this.state.hidden ? 'More' : 'Hide' }( this.state.hidden ?…extra meta… :null));}} );R E - R E N D E RS
C O M P O N E N T SL E T ' S TA L K A B I T M O R E A B O U T
C O M P O S A B L E
Howdy, { this.props.user.nickname }
B U I L D I N G B LO C KS O F O U R A P P L I C AT I O N
………
const Post = React.createClass( {…{ this.props.post.content}…
T E S TA B L E
P R E V E N T S XS S
{ this.props.content }<img src="javascript:alert('XSS');">
N OT T E M P L AT E S
{{#each posts}}{{#if author}}{{/each}}{{^posts}}Not Found{{/posts}}
R E U S A B L E
…
AV ATA R = I M G + H O V E R J S
W A I T!
K E E P LO G I C A N D M A R K U P …A P O P U L A R B E S T P R A C T I C E S A Y S …
… S E PA R AT E !
S E PA R AT I O N O F C O N C E R N S I S G O O D, R I G H T ?
W H E N D O W E N E E D A N E V E N T H A N D L E RW I T H O U T T H E D O M E L E M E N T I T I S B O U N D TO ?
W H E N D O W E N E E D A N E V E N T H A N D L E RW I T H O U T T H E D O M E L E M E N T I T I S B O U N D TO ?onClick()
W H E N D O W E N E E D A D O M E L E M E N T W I T H O U TT H E E V E N T H A N D L E R S F O R I T S A C T I O N S ?onClick()
H TM L
D I S P L AY LO G I C
T H E S A M EC O N C E R N
H TM LJ S
R E - R E N D E R I N G
V I R T U A L D O M
0 . R U N r e n d e r ( )O N E V E RY U P D A T E
1 . D I F F W I T H P R E V I O U S T R E EO N E V E RY U P D A T E
http://calendar.perfplanet.com/2013/diff/
2 . CO M P U T E M I N I M U M S E TO F D O M C H A N G E SO N E V E RY U P D A T E
3 . B ATC H - E X E C U T E A L L D O M U P D AT E SO N E V E RY U P D A T E
V I R T U A L D O M : N OT O N LY S P E E D!
S E R V E R-S I D ER E N D E R I N G
S V G , V M L ,C A N V A S
R U N N I N G I N AW E B W O R K E R
D E C L A R AT I V E
sample
M A G I C!
render() {return ({ this.props.post.author }{ this.state.hidden ? 'More' : 'Hide' }( this.state.hidden ?…extra meta… :null));}
RO U T E R + S TAT Ehttp://redux.js.orghttps://github.com/reactjs/react-routerhttps://egghead.io
A RC H I T E C T U R E
http://github.com/Automattic/wp-calypso
L E T ' S C H AT
S U M M A RY
C O M P O N E N T S , N OT T E M P L AT E S
R E - R E N D E R , D O N ' T TO U C HT H E D O M
V I R T U A L D O M I S S I M P L E ,FA S T, F U NL E T ' S TA L K A B O U T
C O N T R I B U TO R D AY!
Q U E S T I O N S ? @ N I KO L AY B