angular 2 vs react

29

Upload: iran-reyes-fleitas

Post on 16-Apr-2017

1.070 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: Angular 2 vs React
Page 2: Angular 2 vs React

About me

● Iran Reyes Fleitas

● 27 years old

● Happy working for Jam3

Disclaimer● More than 3 years working full with AngularJS

● Switched to React at the end of 2015

Page 3: Angular 2 vs React

This is not a fight

Page 4: Angular 2 vs React

Table of Content

1. Framework vs Library2. Typescript vs ES63. JSX vs HTML Templates4. Web Components5. Size6. CSS Scoping7. Performance8. Native Support9. Server Rendering

10. Routing11. Testing12. Animations13. Packaging

Page 5: Angular 2 vs React

Framework vs Library

Page 6: Angular 2 vs React

Framework vs LibraryAngular is FULL

● Routing

● Testing

● Structure

● Recommended Packaging

● Recommended Language

● Web API calls

● Templating

● Forms

● Style Scoping

Page 7: Angular 2 vs React

Framework vs Library

React is “EMPTY”● Addons

● Many react external libraries

● Easily integration with 3rd parties

Page 8: Angular 2 vs React

WAIT

Page 9: Angular 2 vs React

How to compare

Looks like Performance Features

Page 10: Angular 2 vs React

How looks like

Angular: https://cli.angular.io/

React: https://github.com/facebookincubator/create-react-app

Page 12: Angular 2 vs React

Performance

Garbage collection

Page 13: Angular 2 vs React

Performance

Javascript

Page 14: Angular 2 vs React

Features - Typescript vs ES6

Your choice!!

● Bad documentation in ES6 for Angular 2

● Typescript fit better for big projects (mmm, I don’t like this)

● Too much code for things that are straightforward

● Another thing to learn and deal

● Less common errors

● Easy Intellisense

● Name replacements

● Better IDE Support

Page 15: Angular 2 vs React

Features - Typescript vs ES6

Middle point

Page 16: Angular 2 vs React

Features - JSX vs HTML TemplatesAngular 2 remains HTML-centric rather than JavaScript-centric

JavaScript is far more powerful than HTML

● No need to learn more new syntax.

● Faster. Easy to debug.

● Intellisense

● Better errors (Angular has a own HTML parser)

● Compile-Time Checking

● Away from the current Web Components standards

Page 17: Angular 2 vs React

Features - JSX vs HTML Templates

Page 18: Angular 2 vs React

Features - Web Components

Custom Elements

HTML Imports

Templates

Shadow DOM

Page 19: Angular 2 vs React

Features - Size

React: 130kb● No gzipped

● No Redux

● No Addons

Angular 2: 560kb● No gzipped

● No RxJS

● No Addons

What this mean?

Page 20: Angular 2 vs React

Features - CSS Scoping

Not by default

=> Inline styling

=> CSS Modules

View Encapsulation

=> Deactivated

=> Compatibility protection

=> Shadow DOM

https://github.com/Wildhoney/ReactShadowhttps://github.com/gajus/react-css-moduleshttps://github.com/css-modules/css-modulesify

https://angular.io/docs/ts/latest/guide/component-styles.html

Page 21: Angular 2 vs React

Features - Native Support

ngReactNative

Page 22: Angular 2 vs React

Features - Server Rendering

● Longer time in the web● Many examples● Real apps using it

● Not completely ready yet● Not many examples● Lack of good articles

SEO PWA

Page 23: Angular 2 vs React

Features - Routing

● Doesn’t have one by default● Most popular: React-router● Good integration with flux and redux

● Comes with one by default● Can be replaced● Native Lazy loading support: AsyncRoute

Page 24: Angular 2 vs React

Features - Routing

Page 25: Angular 2 vs React

Features - Testing

● Comes with Karma(Test runner)● Comes with Protractor(E2E tests)● Dependency Injection

● “Doesn’t” have one by default: ReactTestUtils● Use Jest to run your tests(Jasmine)● Enzyme + Mocha● Use Karma and Protractor

Page 26: Angular 2 vs React

Features - Animations

● Animation Library 2.0○ http://slides.yearofmoo.com/ng-conf-2016-slides/index.html

● “Doesn’t” have one by default: ○ ReactCSSTransitionGroup○ ReactTransitionGroup

● React F1● React Motion

So much better!!!!!

Page 27: Angular 2 vs React

● Full documented for SystemJS● Well documented for Webpack● Poor documented for Browserify● Some moves to Rollup

Features - Packaging

● Browserify● WebPack● SystemJS● UMD

Page 28: Angular 2 vs React

Hard conclusions

Choose whatever ;-)

Page 29: Angular 2 vs React

Thanks