react, flux, es6 and problems we met

26
Ihor Harahatyi Executive Software Delivery Boy (I feel good about myself) @

Upload: ihor-harahatyi

Post on 13-Apr-2017

1.349 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: React, Flux, ES6 and problems we met

Ihor HarahatyiExecutive Software Delivery Boy

(I feel good about myself)

@

Page 2: React, Flux, ES6 and problems we met

Let’s speak about:

+ REACT + FLUX+ Yahoo’s Fluxible+ ES6 for REACT+ Problems we met

Not now:

- REACT without FLUX- Other realizations of FLUX

Page 3: React, Flux, ES6 and problems we met

Lot of code + Frequent changes = Many bugs

Page 4: React, Flux, ES6 and problems we met

html + jQuery

.html

<header><div class="name"></div>

</header>

.js

$.post('/login', credentials, function( user ) {// Modify the DOM here$('header .name').show().text( user.name );

});

Page 5: React, Flux, ES6 and problems we met

REACT.js

class Header extends React.Component {render() {return (<header>{ this.props.name ?<div>this.props.name</div> : null }

</header>);

}}

Use:

<Header name={name_from_store} />

Page 6: React, Flux, ES6 and problems we met

Do not refresh. Rerender!

Page 7: React, Flux, ES6 and problems we met

It’s fast

Page 8: React, Flux, ES6 and problems we met

MVC

Page 9: React, Flux, ES6 and problems we met

More models

Page 10: React, Flux, ES6 and problems we met

FLUX

Page 11: React, Flux, ES6 and problems we met

Fluxible

Page 12: React, Flux, ES6 and problems we met

Fluxible

Page 13: React, Flux, ES6 and problems we met

ES6http://es6-features.org/

Page 14: React, Flux, ES6 and problems we met

Classes

ES5

var Photo = React.createClass({handleDoubleTap: function(e) { },render: function() { },});

ES6

class Photo extends React.Component {handleDoubleTap(e) { }render() { }}

Page 15: React, Flux, ES6 and problems we met

Props and StateES5

var Counter = React.createClass({getDefaultProps: function() {return { start: 0 };},getInitialState: function() {return { currentCount: this.props.start, };},});

ES6

class Video extends React.Component {static defaultProps = { start: 0 }state = { currentCount: this.props.start }}

Page 16: React, Flux, ES6 and problems we met

Use arrow functionsES6

class ClickBtn extends React.Component {onButtonClick(e) {alert('Clicked!');}render() {return (<button onClick={this.onButtonClick.bind(this)>

Click Me!<button>);

}}

ES6

onButtonClick = (e) => { alert('Clicked!'); }

Page 17: React, Flux, ES6 and problems we met

Destructuring and Spread attributesES6

class AutoloadingPostsGrid extends React.Component {render() {let {className,...others,} = this.props;

return (<div className={className}><PostsGrid {...others} /><button onClick={this.loadMore}>Load more<button><div>);}}

Page 18: React, Flux, ES6 and problems we met

Problems?

Page 19: React, Flux, ES6 and problems we met

Markup Engineers

Page 20: React, Flux, ES6 and problems we met

World changes

Page 21: React, Flux, ES6 and problems we met

No documentation

Real Programmers don’t write specs. Users shouldconsider themselves lucky to get any programs atall, and take what they get.

(Real Programmer’s rulebook)

Page 22: React, Flux, ES6 and problems we met

You should not change DOM

Page 23: React, Flux, ES6 and problems we met

We don’t have good UI Kit

Page 24: React, Flux, ES6 and problems we met

When use REACT:

▶ You have lot of componets.▶ Your components change frequently.▶ You’re ready to avoid mentioned problems.

Page 25: React, Flux, ES6 and problems we met

React Native

Page 26: React, Flux, ES6 and problems we met

Things to read

▶ reactjs for stupid people▶ flux for stupid people