SlideShare a Scribd company logo
Hasan @ DEV6 – #WEBU17
?
Hasan @ DEV6 – #WEBU17
Hasan @ DEV6 – #WEBU17
Hasan Ahmad
Senior Consultant @ DEV6
Lead @ DevC Toronto
https://www.dev6.com/
https://www.facebook.com/groups/DevCToronto/
Hasan @ DEV6 – #WEBU17
Front-end frameworks have more in common than you might expect
Component based architecture
View-Model / State management
Routing views with URLs
Hasan @ DEV6 – #WEBU17
Components
Angular: Decorate classes with component life-cycle hooks
React: ES6 inheritance provides interfaces for life-cycle hooks
Hasan @ DEV6 – #WEBU17
@Component({selector:	'greet',	template:	'Hello	{{name}}!’})		
class	Greet	{		
	name:	string	=	'World';	
}	
class	Welcome	extends	React.component	{	
	render()	{		
	 	return	<h1>Hello,	{this.props.name}</h1>		
	}		
}
Hasan @ DEV6 – #WEBU17
ngOnChanges()	–	when	a	data	binding	has	changed	
ngOnInit()	–	when	angular	has	already	displayed	bound	data	
ngOnCheck()	–	manual	change	detection	
ngAfterContentInit()	-	…	
ngAfterContentInitChecked()	-	…	
ngAfterViewInit()	-	…	
ngAfterViewInitChecked()	-	…	
ngOnDestroy()	–	right	before	angular	removes	a	component
Hasan @ DEV6 – #WEBU17
constructor()	–	component	is	created	
componentWillMount()	–	before	a	component	has	been	attached	to	view	
render()	–	return	the	react	view	element	
componentDidMount()	–	after	react	has	attached	component	to	view	
componentWillRecieveProps()	-	…	
shouldComponentUpdate()	-	…	
componentWillUpdate()	-	…	
componentDidUpdate()	-	after	react	has	updated	a	component	
componentWillUnmount()	–	before	react	removes	a	component
Hasan @ DEV6 – #WEBU17
export	class	PeekABoo	implements	OnInit	{	
	constructor(private	logger:	LoggerService)	{	}	
	//	implement	OnInit's	`ngOnInit`	method	
	ngOnInit()	{	
	 	this.logIt(`OnInit`);		
	}		
	logIt(msg:	string)	{		
	 	this.logger.log(`#${nextId++}	${msg}`);		
	}	
}
Hasan @ DEV6 – #WEBU17
class	Clock	extends	React.Component	{	
constructor(props)	{		
super(props);		
this.state	=	{date:	new	Date()};		
}	
componentDidMount()	{		
	this.timerID	=	setInterval(	()	=>	this.tick(),	1000	);		
}	
componentWillUnmount()	{		
	clearInterval(this.timerID);		
}		
//...		
}
Hasan @ DEV6 – #WEBU17
Data Binding
Angular - flexible data binding options, including two-way
React - One-way data binding, lift state up
Hasan @ DEV6 – #WEBU17
Component to
DOM
Interpolation and Property Binding
One-way binding: Value goes from component data property to a target
element property
DOM to
Component
Event Binding: user interacted with page, bring that back to the component
Both Two-Way Binding: update data as soon as it has been changed by the user
Hasan @ DEV6 – #WEBU17
Handling State
Angular – Mutable data, services as singletons (can opt for immutable too)
React – state & props, flux, redux
Hasan @ DEV6 – #WEBU17
Service is a singleton – only one instance in memory
Components can mutate data in services, everyone who injects a
service can see the altered state
Angular will automatically re-draw the UI with the new data
(Change Detection + Zones + Data Binding)
Hasan @ DEV6 – #WEBU17
Components have their own state, react renders components when
their state changes
By default, you have to maintain parent-child relationships to state,
using props
redux: have one giant state object
Hasan @ DEV6 – #WEBU17
Store Single big JSON, all state for entire application
Reducer Update store, return a new state
Action Dispatched to trigger a state change
Follow up on redux.js.org
Hasan @ DEV6 – #WEBU17
Layout & Styling
Angular has embraced Shadow DOM +View Encapsulation for styling
components
React is compatible with many styling approaches: traditional CSS,
bootstrap, and flexbox
Hasan @ DEV6 – #WEBU17
@Component({		
selector:	'hero-details',		
template:	`		
<h2>{{hero.name}}</h2>		
<hero-team	[hero]=hero></hero-team>		
<ng-content></ng-content>		
`,		
styleUrls:	['app/hero-details.component.css']		
})	
export	class	HeroDetailsComponent	{	/*	.	.	.	*/	}
Hasan @ DEV6 – #WEBU17
What is Shadow DOM?
Shadow DOM is included in the Web Components standard by W3C
Refers to the ability to include a subtree of DOM elements
Allows DOM implementation to be hidden from the rest of the
document
Hasan @ DEV6 – #WEBU17
<hero-details	_nghost-pmm-5>	
<h2	_ngcontent-pmm-5>Mister	Fantastic</h2>		
<hero-team	_ngcontent-pmm-5	_nghost-pmm-6>		
	<h3	_ngcontent-pmm-6>Team</h3>		
</hero-team>		
</hero-detail>
Hasan @ DEV6 – #WEBU17
render(props,	context)	{		
	const	notes	=	this.props.notes;		
	return	<ul	className='notes'>{notes.map(this.renderNote)}</ul>;	
}	
render(props,	context)	{		
	const	notes	=	this.props.notes;		
	const	style	=	{		
	 	margin:	'0.5em',		
	 	paddingLeft:	0,		
	 	listStyle:	'none'		
	};		
	return	<ul	style={style}>{notes.map(this.renderNote)}</ul>;		
}	
https://survivejs.com/react/advanced-techniques/styling-react/
Hasan @ DEV6 – #WEBU17
import	React	from	'react'		
import	injectSheet	from	'react-jss'		
const	styles	=	{		
	button:	{		
	 	background:	props	=>	props.color	},		
	label:	{		
	 	fontWeight:	'bold'		
	}		
}		
const	Button	=	({classes,	children})	=>	(		
	<button	className={classes.button}>		
	 	<span	className={classes.label}>		
	 	 	{children}		
	 	</span>		
	</button>		
)		
export	default	injectSheet(styles)(Button)	
https://github.com/cssinjs/jss
Hasan @ DEV6 – #WEBU17
var	Block	=	require('jsxstyle/Block');		
var	React	=	require('react');		
var	MyComponent	=	React.createClass({		
render:	function()	{		
	return	<Block	color="red">Hello,	world!</Block>;		
}		
});	
https://github.com/smyte/jsxstyle
Hasan @ DEV6 – #WEBU17
Routing
Angular has one routing model, driven by the URL
@angular/router is engineered for many scenarios
React has many different options, depending on your app architecture
react-router, fluxxor-react-router, react-redux-router
Hasan @ DEV6 – #WEBU17
template:	`		
<h1>Angular	Router</h1>		
<nav>		
<a	routerLink="/crisis-center"	routerLinkActive="active">Crisis	Center</a>		
<a	routerLink="/heroes"	routerLinkActive="active">Heroes</a>		
</nav>		
<router-outlet></router-outlet>		
`	
const	appRoutes:	Routes	=	[		
{	path:	'crisis-center',	component:	CrisisListComponent	},		
{	path:	'hero/:id',	component:	HeroDetailComponent	},		
{	path:	'heroes',	component:	HeroListComponent,	data:	{	title:	'Heroes	List'	}	},		
{	path:	'',	redirectTo:	'/heroes',	pathMatch:	'full'	},		
{	path:	'**',	component:	PageNotFoundComponent	}		
];
Hasan @ DEV6 – #WEBU17
//	./src/index.jsx		
import	React,	{	Component	}	from	'react';		
import	{	render	}	from	'react-dom';		
//	Import	routing	components		
import	{Router,	Route}	from	'react-router';		
class	Home	extends	Component	{		
render(){		
	return	(<h1>Hi</h1>);		
}		
}	
render(		
	<Router>		
	 	<!--Each	route	is	defined	with	Route-->		
	 	<Route	path="/"	component={Home}/>		
	</Router>,		
	document.getElementById('container')		
);	
https://scotch.io/tutorials/routing-react-apps-the-complete-guide
Hasan @ DEV6 – #WEBU17
import	React	from	'react'		
import	ReactDOM	from	'react-dom'		
import	{	createStore,	combineReducers	}	from	'redux'		
import	{	Provider	}	from	'react-redux'		
import	{	Router,	Route,	browserHistory	}	from	'react-router'		
import	{	syncHistoryWithStore,	routerReducer	}	from	'react-router-redux'		
import	reducers	from	'<project-path>/reducers'		
const	store	=	createStore(	combineReducers({	...reducers,	routing:	routerReducer	})	)		
//	Create	an	enhanced	history	that	syncs	navigation	events	with	the	store		
const	history	=	syncHistoryWithStore(browserHistory,	store)		
ReactDOM.render(		
<Provider	store={store}>		
<Router	history={history}>		
<Route	path="/"	component={App}>		
<Route	path="foo"	component={Foo}/>		
<Route	path="bar"	component={Bar}/>		
</Route>		
</Router>		
</Provider>,		
document.getElementById('mount')		
)	
https://github.com/reactjs/react-router-redux
Hasan @ DEV6 – #WEBU17
Testing
Angular comes with extensive support for jasmine with karma and
protractor
React varies by project, some use Jest, others use Mocha/Chai/Enzyme
Hasan @ DEV6 – #WEBU17
Cross-platform apps
Extend cross platform experience beyond the browser
Progressive Web Applications
Cordova / Hybrid Applications
NativeScript / React Native
Hasan @ DEV6 – #WEBU17
Angular + React = ?
react-native-renderer – Angular project in a react native app
ng-redux – Use redux (popularized by React) in your Angular projects
Hasan @ DEV6 – #WEBU17
Summary
Equal, yet different:Two approaches to solving common problems all
developers face.
Choice between Angular and React is ultimately driven by an
organization’s development philosophy.
Hasan @ DEV6 – #WEBU17
ThankYou!
Questions?

More Related Content

PDF
Building Progressive Web Apps for Android and iOS
PDF
Progressive Web Apps
PDF
Chrome enchanted 2015
PDF
Thinking in Components
PDF
Web Components & Polymer 1.0 (Webinale Berlin)
PPTX
Building single page applications
KEY
An Introduction to webOS
PDF
The web - What it has, what it lacks and where it must go - Istanbul
Building Progressive Web Apps for Android and iOS
Progressive Web Apps
Chrome enchanted 2015
Thinking in Components
Web Components & Polymer 1.0 (Webinale Berlin)
Building single page applications
An Introduction to webOS
The web - What it has, what it lacks and where it must go - Istanbul

What's hot (20)

PDF
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
PDF
Booting up with polymer
PDF
jQuery 1.9 and 2.0 - Present and Future
PDF
Booting up with polymer
PDF
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
PDF
Building a Secure App with Google Polymer and Java / Spring
PPTX
Disrupting the application eco system with progressive web applications
PDF
AtlasCamp 2015: Using add-ons to build add-ons
PPT
You Know WebOS
PDF
Unlock the next era of UI design with Polymer
PDF
Building an HTML5 Video Player
PDF
AspNetWhitePaper
PDF
Usability in the GeoWeb
PPTX
Enough with the JavaScript already!
PDF
Enjoy the vue.js
PDF
Externalizing Chatter Using Heroku, Angular.js, Node.js and Chatter REST APIs
PDF
The Complementarity of React and Web Components
PDF
HTML5 and the dawn of rich mobile web applications
PDF
Modern Web Application Development Workflow - EclipseCon Europe 2014
PDF
Our application got popular and now it breaks
Oleh Zasadnyy "Progressive Web Apps: line between web and native apps become ...
Booting up with polymer
jQuery 1.9 and 2.0 - Present and Future
Booting up with polymer
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
Building a Secure App with Google Polymer and Java / Spring
Disrupting the application eco system with progressive web applications
AtlasCamp 2015: Using add-ons to build add-ons
You Know WebOS
Unlock the next era of UI design with Polymer
Building an HTML5 Video Player
AspNetWhitePaper
Usability in the GeoWeb
Enough with the JavaScript already!
Enjoy the vue.js
Externalizing Chatter Using Heroku, Angular.js, Node.js and Chatter REST APIs
The Complementarity of React and Web Components
HTML5 and the dawn of rich mobile web applications
Modern Web Application Development Workflow - EclipseCon Europe 2014
Our application got popular and now it breaks
Ad

Similar to Angular vs React for Web Application Development (20)

PDF
Nuxt.JS Introdruction
PDF
Front End Development for Back End Developers - Devoxx UK 2017
PPTX
PPTX
Html5 & less css
PPTX
How i made the responsive mobile version of
PPTX
An introduction to Vue.js
PPT
PDF
AngularJS 101 - Everything you need to know to get started
PDF
Leveraging the Power of Custom Elements in Gutenberg
PDF
ReactJS vs AngularJS - Head to Head comparison
PPTX
Getting Started with React v16
PDF
[Bristol WordPress] Supercharging WordPress Development
PDF
Ajax Performance Tuning and Best Practices
PPTX
crtical points for customizing Joomla templates
PDF
Node.js & Twitter Bootstrap Crash Course
PPTX
Nodejs.meetup
PPTX
The future of web development write once, run everywhere with angular.js and ...
PDF
The future of web development write once, run everywhere with angular js an...
PDF
Web Components v1
KEY
It's a Mod World - A Practical Guide to Rocking Modernizr
Nuxt.JS Introdruction
Front End Development for Back End Developers - Devoxx UK 2017
Html5 & less css
How i made the responsive mobile version of
An introduction to Vue.js
AngularJS 101 - Everything you need to know to get started
Leveraging the Power of Custom Elements in Gutenberg
ReactJS vs AngularJS - Head to Head comparison
Getting Started with React v16
[Bristol WordPress] Supercharging WordPress Development
Ajax Performance Tuning and Best Practices
crtical points for customizing Joomla templates
Node.js & Twitter Bootstrap Crash Course
Nodejs.meetup
The future of web development write once, run everywhere with angular.js and ...
The future of web development write once, run everywhere with angular js an...
Web Components v1
It's a Mod World - A Practical Guide to Rocking Modernizr
Ad

More from FITC (20)

PPTX
Cut it up
PDF
Designing for Digital Health
PDF
Profiling JavaScript Performance
PPTX
Surviving Your Tech Stack
PDF
How to Pitch Your First AR Project
PDF
Start by Understanding the Problem, Not by Delivering the Answer
PDF
Cocaine to Carrots: The Art of Telling Someone Else’s Story
PDF
Everyday Innovation
PDF
HyperLight Websites
PDF
Everything is Terrifying
PDF
Post-Earth Visions: Designing for Space and the Future Human
PDF
The Rise of the Creative Social Influencer (and How to Become One)
PDF
East of the Rockies: Developing an AR Game
PDF
Creating a Proactive Healthcare System
PDF
World Transformation: The Secret Agenda of Product Design
PDF
The Power of Now
PDF
High Performance PWAs
PDF
Rise of the JAMstack
PDF
From Closed to Open: A Journey of Self Discovery
PDF
Projects Ain’t Nobody Got Time For
Cut it up
Designing for Digital Health
Profiling JavaScript Performance
Surviving Your Tech Stack
How to Pitch Your First AR Project
Start by Understanding the Problem, Not by Delivering the Answer
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Everyday Innovation
HyperLight Websites
Everything is Terrifying
Post-Earth Visions: Designing for Space and the Future Human
The Rise of the Creative Social Influencer (and How to Become One)
East of the Rockies: Developing an AR Game
Creating a Proactive Healthcare System
World Transformation: The Secret Agenda of Product Design
The Power of Now
High Performance PWAs
Rise of the JAMstack
From Closed to Open: A Journey of Self Discovery
Projects Ain’t Nobody Got Time For

Recently uploaded (20)

PPTX
CroxyProxy Instagram Access id login.pptx
PDF
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
DevOps & Developer Experience Summer BBQ
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
PDF
Google’s NotebookLM Unveils Video Overviews
PDF
REPORT: Heating appliances market in Poland 2024
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PPTX
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Chapter 2 Digital Image Fundamentals.pdf
PDF
KodekX | Application Modernization Development
PPTX
Belt and Road Supply Chain Finance Blockchain Solution
PDF
NewMind AI Monthly Chronicles - July 2025
CroxyProxy Instagram Access id login.pptx
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
GamePlan Trading System Review: Professional Trader's Honest Take
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
DevOps & Developer Experience Summer BBQ
Chapter 3 Spatial Domain Image Processing.pdf
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
A Day in the Life of Location Data - Turning Where into How.pdf
Google’s NotebookLM Unveils Video Overviews
REPORT: Heating appliances market in Poland 2024
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
Transforming Manufacturing operations through Intelligent Integrations
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Understanding_Digital_Forensics_Presentation.pptx
Chapter 2 Digital Image Fundamentals.pdf
KodekX | Application Modernization Development
Belt and Road Supply Chain Finance Blockchain Solution
NewMind AI Monthly Chronicles - July 2025

Angular vs React for Web Application Development

  • 1. Hasan @ DEV6 – #WEBU17 ?
  • 2. Hasan @ DEV6 – #WEBU17
  • 3. Hasan @ DEV6 – #WEBU17 Hasan Ahmad Senior Consultant @ DEV6 Lead @ DevC Toronto https://www.dev6.com/ https://www.facebook.com/groups/DevCToronto/
  • 4. Hasan @ DEV6 – #WEBU17 Front-end frameworks have more in common than you might expect Component based architecture View-Model / State management Routing views with URLs
  • 5. Hasan @ DEV6 – #WEBU17 Components Angular: Decorate classes with component life-cycle hooks React: ES6 inheritance provides interfaces for life-cycle hooks
  • 6. Hasan @ DEV6 – #WEBU17 @Component({selector: 'greet', template: 'Hello {{name}}!’}) class Greet { name: string = 'World'; } class Welcome extends React.component { render() { return <h1>Hello, {this.props.name}</h1> } }
  • 7. Hasan @ DEV6 – #WEBU17 ngOnChanges() – when a data binding has changed ngOnInit() – when angular has already displayed bound data ngOnCheck() – manual change detection ngAfterContentInit() - … ngAfterContentInitChecked() - … ngAfterViewInit() - … ngAfterViewInitChecked() - … ngOnDestroy() – right before angular removes a component
  • 8. Hasan @ DEV6 – #WEBU17 constructor() – component is created componentWillMount() – before a component has been attached to view render() – return the react view element componentDidMount() – after react has attached component to view componentWillRecieveProps() - … shouldComponentUpdate() - … componentWillUpdate() - … componentDidUpdate() - after react has updated a component componentWillUnmount() – before react removes a component
  • 9. Hasan @ DEV6 – #WEBU17 export class PeekABoo implements OnInit { constructor(private logger: LoggerService) { } // implement OnInit's `ngOnInit` method ngOnInit() { this.logIt(`OnInit`); } logIt(msg: string) { this.logger.log(`#${nextId++} ${msg}`); } }
  • 10. Hasan @ DEV6 – #WEBU17 class Clock extends React.Component { constructor(props) { super(props); this.state = {date: new Date()}; } componentDidMount() { this.timerID = setInterval( () => this.tick(), 1000 ); } componentWillUnmount() { clearInterval(this.timerID); } //... }
  • 11. Hasan @ DEV6 – #WEBU17 Data Binding Angular - flexible data binding options, including two-way React - One-way data binding, lift state up
  • 12. Hasan @ DEV6 – #WEBU17 Component to DOM Interpolation and Property Binding One-way binding: Value goes from component data property to a target element property DOM to Component Event Binding: user interacted with page, bring that back to the component Both Two-Way Binding: update data as soon as it has been changed by the user
  • 13. Hasan @ DEV6 – #WEBU17 Handling State Angular – Mutable data, services as singletons (can opt for immutable too) React – state & props, flux, redux
  • 14. Hasan @ DEV6 – #WEBU17 Service is a singleton – only one instance in memory Components can mutate data in services, everyone who injects a service can see the altered state Angular will automatically re-draw the UI with the new data (Change Detection + Zones + Data Binding)
  • 15. Hasan @ DEV6 – #WEBU17 Components have their own state, react renders components when their state changes By default, you have to maintain parent-child relationships to state, using props redux: have one giant state object
  • 16. Hasan @ DEV6 – #WEBU17 Store Single big JSON, all state for entire application Reducer Update store, return a new state Action Dispatched to trigger a state change Follow up on redux.js.org
  • 17. Hasan @ DEV6 – #WEBU17 Layout & Styling Angular has embraced Shadow DOM +View Encapsulation for styling components React is compatible with many styling approaches: traditional CSS, bootstrap, and flexbox
  • 18. Hasan @ DEV6 – #WEBU17 @Component({ selector: 'hero-details', template: ` <h2>{{hero.name}}</h2> <hero-team [hero]=hero></hero-team> <ng-content></ng-content> `, styleUrls: ['app/hero-details.component.css'] }) export class HeroDetailsComponent { /* . . . */ }
  • 19. Hasan @ DEV6 – #WEBU17 What is Shadow DOM? Shadow DOM is included in the Web Components standard by W3C Refers to the ability to include a subtree of DOM elements Allows DOM implementation to be hidden from the rest of the document
  • 20. Hasan @ DEV6 – #WEBU17 <hero-details _nghost-pmm-5> <h2 _ngcontent-pmm-5>Mister Fantastic</h2> <hero-team _ngcontent-pmm-5 _nghost-pmm-6> <h3 _ngcontent-pmm-6>Team</h3> </hero-team> </hero-detail>
  • 21. Hasan @ DEV6 – #WEBU17 render(props, context) { const notes = this.props.notes; return <ul className='notes'>{notes.map(this.renderNote)}</ul>; } render(props, context) { const notes = this.props.notes; const style = { margin: '0.5em', paddingLeft: 0, listStyle: 'none' }; return <ul style={style}>{notes.map(this.renderNote)}</ul>; } https://survivejs.com/react/advanced-techniques/styling-react/
  • 22. Hasan @ DEV6 – #WEBU17 import React from 'react' import injectSheet from 'react-jss' const styles = { button: { background: props => props.color }, label: { fontWeight: 'bold' } } const Button = ({classes, children}) => ( <button className={classes.button}> <span className={classes.label}> {children} </span> </button> ) export default injectSheet(styles)(Button) https://github.com/cssinjs/jss
  • 23. Hasan @ DEV6 – #WEBU17 var Block = require('jsxstyle/Block'); var React = require('react'); var MyComponent = React.createClass({ render: function() { return <Block color="red">Hello, world!</Block>; } }); https://github.com/smyte/jsxstyle
  • 24. Hasan @ DEV6 – #WEBU17 Routing Angular has one routing model, driven by the URL @angular/router is engineered for many scenarios React has many different options, depending on your app architecture react-router, fluxxor-react-router, react-redux-router
  • 25. Hasan @ DEV6 – #WEBU17 template: ` <h1>Angular Router</h1> <nav> <a routerLink="/crisis-center" routerLinkActive="active">Crisis Center</a> <a routerLink="/heroes" routerLinkActive="active">Heroes</a> </nav> <router-outlet></router-outlet> ` const appRoutes: Routes = [ { path: 'crisis-center', component: CrisisListComponent }, { path: 'hero/:id', component: HeroDetailComponent }, { path: 'heroes', component: HeroListComponent, data: { title: 'Heroes List' } }, { path: '', redirectTo: '/heroes', pathMatch: 'full' }, { path: '**', component: PageNotFoundComponent } ];
  • 26. Hasan @ DEV6 – #WEBU17 // ./src/index.jsx import React, { Component } from 'react'; import { render } from 'react-dom'; // Import routing components import {Router, Route} from 'react-router'; class Home extends Component { render(){ return (<h1>Hi</h1>); } } render( <Router> <!--Each route is defined with Route--> <Route path="/" component={Home}/> </Router>, document.getElementById('container') ); https://scotch.io/tutorials/routing-react-apps-the-complete-guide
  • 27. Hasan @ DEV6 – #WEBU17 import React from 'react' import ReactDOM from 'react-dom' import { createStore, combineReducers } from 'redux' import { Provider } from 'react-redux' import { Router, Route, browserHistory } from 'react-router' import { syncHistoryWithStore, routerReducer } from 'react-router-redux' import reducers from '<project-path>/reducers' const store = createStore( combineReducers({ ...reducers, routing: routerReducer }) ) // Create an enhanced history that syncs navigation events with the store const history = syncHistoryWithStore(browserHistory, store) ReactDOM.render( <Provider store={store}> <Router history={history}> <Route path="/" component={App}> <Route path="foo" component={Foo}/> <Route path="bar" component={Bar}/> </Route> </Router> </Provider>, document.getElementById('mount') ) https://github.com/reactjs/react-router-redux
  • 28. Hasan @ DEV6 – #WEBU17 Testing Angular comes with extensive support for jasmine with karma and protractor React varies by project, some use Jest, others use Mocha/Chai/Enzyme
  • 29. Hasan @ DEV6 – #WEBU17 Cross-platform apps Extend cross platform experience beyond the browser Progressive Web Applications Cordova / Hybrid Applications NativeScript / React Native
  • 30. Hasan @ DEV6 – #WEBU17 Angular + React = ? react-native-renderer – Angular project in a react native app ng-redux – Use redux (popularized by React) in your Angular projects
  • 31. Hasan @ DEV6 – #WEBU17 Summary Equal, yet different:Two approaches to solving common problems all developers face. Choice between Angular and React is ultimately driven by an organization’s development philosophy.
  • 32. Hasan @ DEV6 – #WEBU17 ThankYou! Questions?