react برای دولوپرها

47

Upload: web-standards-school

Post on 16-Apr-2017

342 views

Category:

Education


5 download

TRANSCRIPT

Page 1: React برای دولوپرها
Page 2: React برای دولوپرها

Hello World!

React for Developers

#irDevConf ■ @sia_mac

Page 3: React برای دولوپرها

ES6The Sixth Edition, known as ECMAScript 2015.

#irDevConf ■ @sia_mac

Page 4: React برای دولوپرها

› How to tackle the React Ecosystem __¬ NPM

¬ JavaScript Module Bundlers

¬ ES6

¬ ReactJS

¬ Routing

¬ Flux#irDevConf ■ @sia_mac

Page 5: React برای دولوپرها

› AMD & CommonJS __

¬ NPM: “Node Package Manager”

¬ Dependencies, Scripts.

¬ AMD (RequireJS) — AngularJS<2, jQuery, BackboneJS,…

¬ CommonJS — ES6.

#irDevConf ■ @sia_mac

Page 6: React برای دولوپرها

› CommonJS A format Writing Modules in Node.JS __

#irDevConf ■ @sia_mac

index.js maths.js:

Page 7: React برای دولوپرها

› CommonJS in Browser __

¬ JavaScript Module Bundlers:

¬ Browserify (*ify)

¬ Webpack (*-loader)

¬ RollupJS

#irDevConf ■ @sia_mac

Page 8: React برای دولوپرها

WebpackJavaScript Module Bundler

#irDevConf ■ @sia_mac

Page 9: React برای دولوپرها

#irDevConf ■ @sia_mac

Page 10: React برای دولوپرها

Webpack != Grunt/Gulp

#irDevConf ■ @sia_mac

Page 11: React برای دولوپرها

› Webpack vs. Grunt/Gulp Diagram __Grunt/Gulp Diagram:

#irDevConf ■ @sia_mac

one.js

two.js

Concat Uglify

...

grid.scss

typography.scss

Compile Minify

...

Browser

Page 12: React برای دولوپرها

› Webpack vs. Grunt/Gulp Diagram __Webpack Diagram:

#irDevConf ■ @sia_mac

one.js

two.js

Concat Uglify

...

grid.scss

typography.scss

Compile Minify

...

BrowserBundle.js

Page 13: React برای دولوپرها

› Webpack vs. Grunt/Gulp Diagram __Grunt/Gulp Diagram:

#irDevConf ■ @sia_mac

one.js

two.js

Concat Uglify

...

grid.scss

typography.scss

Compile Minify

...

Browser

Page 14: React برای دولوپرها

› How to tackle the React Ecosystem __¬ NPM

¬ JavaScript Module Bundlers

¬ ES6 ✔ “https://goo.gl/81ha0d”

¬ ReactJS

¬ Routing

¬ Flux#irDevConf ■ @sia_mac

Page 15: React برای دولوپرها

ReactA JAVASCRIPT LIBRARY FOR BUILDING USER INTERFACES

#irDevConf ■ @sia_mac

Page 16: React برای دولوپرها

› Facebook, Mother of dragons __¬ Started by Facebook in 2013.

¬ Motivation — Building Large apps with data.

¬ Over 45k+ Star on Github.

¬ Sites Using React: ¬ Facebook, Instagram, Dropbox, PayPal, Uber, …

#irDevConf ■ @sia_mac

Page 17: React برای دولوپرها

› Meet React __

#irDevConf ■ @sia_mac

NOT Another Framework!Just a library for creating User Interfaces.

Page 18: React برای دولوپرها

› Meet React __

#irDevConf ■ @sia_mac

Renders your User Interfaces and responds to Events.

Page 19: React برای دولوپرها

› Meet React __

#irDevConf ■ @sia_mac

React just “V” in ‘MVC’ (View)

Page 20: React برای دولوپرها

› Meet React __

#irDevConf ■ @sia_mac

¬ React Has … ¬ No Controllers. No Directives.

¬ No Templates. No Global EventListener.

¬ No Models. No View Models.

¬ No Dirty Checking.

Page 21: React برای دولوپرها

› Meet React __

#irDevConf ■ @sia_mac

Everything is a Component! Everything is a Component! Everything is a Component! Everything is a Component! Everything is a Component!

Page 22: React برای دولوپرها
Page 23: React برای دولوپرها

Main component:

Page 24: React برای دولوپرها

Header CP

Page 25: React برای دولوپرها

Header CP

Sidebar CP

Page 26: React برای دولوپرها

Header CP

Sidebar CP Hero CP

Page 27: React برای دولوپرها

› The Most important in Performance: __

#irDevConf ■ @sia_mac

Virtual DOM

Page 28: React برای دولوپرها

› Virtual DOM: __¬ Simple & Fast & Smart.

¬ On Every update:

¬ React builds a new virtual DOM subtree.

¬ Diffs it with the old One.

¬ Computes the minimal set of DOM mutations and puts them in a queue.

¬ Batch executes all updates.#irDevConf ■ @sia_mac

Page 29: React برای دولوپرها

› JSX Allows you to write JS and XML Together: __

#irDevConf ■ @sia_mac

React JSX is a Sugar–Syntax for JS!

Page 30: React برای دولوپرها

› Traditional Data flows: __¬ No Framework: Any component can communicate with

any other component.

¬ BackboneJS: Pub–Sub.

¬ AngularJS: 2–way binding and $digest loop.

¬ ReactJS: 1–way data flow:

¬ Data handed from Parent to Child “Props”.

#irDevConf ■ @sia_mac

Page 31: React برای دولوپرها

React vs. jQuery

#irDevConf ■ @sia_mac

Page 32: React برای دولوپرها

› Playground __

#irDevConf ■ @sia_mac

I’ve achieved 0 Pokémon.

Another Pokémon +

Page 33: React برای دولوپرها

› Playground __

#irDevConf ■ @sia_mac

I’ve achieved 1 Pokémon.

Another Pokémon +

Page 34: React برای دولوپرها

› Playground __

#irDevConf ■ @sia_mac

I’ve achieved 2 Pokémons.

Another Pokémon +

Page 35: React برای دولوپرها

› Playground __

#irDevConf ■ @sia_mac

I’ve achieved 2 Pokémons.

Another Pokémon +

Button Component

Page 36: React برای دولوپرها

› Playground __

#irDevConf ■ @sia_mac

I’ve achieved 2 Pokémons.

Another Pokémon +

Page 37: React برای دولوپرها

#irDevConf ■ @sia_mac

init

Button Component “jQuery”

thumbsUp

render

cacheElements handleClick

Page 38: React برای دولوپرها

#irDevConf ■ @sia_mac

init

Button Component “React”

handleClick

thumbsUp

render

cacheElements

Page 39: React برای دولوپرها

› State & Props: __

¬ Every Component has ‘state’ and ‘props’.

¬ ‘state’ is mutable and ‘props’ is immutable.

¬ Re-Render (Virtual DOM) the whole app once the `state` changes.

#irDevConf ■ @sia_mac

Page 40: React برای دولوپرها

› Why React? __

#irDevConf ■ @sia_mac

¬ Fast and Smart. ¬ Unidirectional data flow from parent components to child components.

¬ Isomorphic (JS apps that can run both client-side and server-side)

¬ Easy to debug & testable. ¬ Use JSX with familiar HTML like syntax for writing react apps.

Page 41: React برای دولوپرها

› Benefits of React? __

#irDevConf ■ @sia_mac

¬ Modular (Reusable)

¬ State–Based (Predictable)

¬ Independent (Testable)

¬ High-Performance (Virtual DOM)

Page 42: React برای دولوپرها

bahamta.com/

mor.com.co/

evand.ir/

cinematicket.org/New Version!

Page 43: React برای دولوپرها

facebook.github.io/react/

References

#irDevConf ■ @sia_mac

www.slideshare.net/AndrewHull/react-js-and-why-its-awesome/

Page 44: React برای دولوپرها

One more thing…

#irDevConf ■ @sia_mac

Page 45: React برای دولوپرها

React NativeA framework for building native apps using React.

#irDevConf ■ @sia_mac

Page 46: React برای دولوپرها

Thursday, Jul 21. 16:30 — 17:30.

“Public Workshop”

#irDevConf ■ @sia_mac

Page 47: React برای دولوپرها