SlideShare a Scribd company logo
1 of 79
ReactJS for Beginners
Oswald Campesato
Consultant/Training:
www.iquarkt.com
ocampesato@yahoo.com
What is ReactJS?
ā€¢ Library for Web Apps (from Facebook)
ā€¢ Provides the ā€œVā€ in ā€œMVCā€
ā€¢ component-based architecture
ā€¢ ES6/JSX (HTML embedded in JavaScript)
ā€¢ 400 components available:
https://github.com/brillout/awesome-react-components
Advantages of ReactJS
ā€¢ highly efficient
ā€¢ easier to write Javascript via JSX
ā€¢ out-of-the-box developer tools
ā€¢ very good for SEO
ā€¢ easy to write UI test cases
ā€¢ http://www.pro-tekconsulting.com/blog/advantages-
disadvantages-of-react-js/
Disadvantages of ReactJS
ā€¢ ReactJS is only a view layer
ā€¢ ReactJS into an MVC framework requires configuration
ā€¢ learning curve for beginners who are new to web
development
ā€¢ Scaffolding is usually needed for transpilation
What are Transpilers?
ā€¢ They convert code from one language to another
ā€¢ Babel (formerly 6to5):
+converts ES6 (some ES7) to ECMA5
+ appears to be the de facto standard
ā€¢ Traceur (Google):
+ converts ES6 to ECMA5
+ used by Angular 2
NOTE: JSX is transpiled by ECMA5
Typical Set-up Tools
ā€¢ Node and npm (installing JS dependencies)
ā€¢ Babel (in HTML Web pages)
ā€¢ Webpack (highly recommended)
ā€¢ NB: you can use Gulp instead of WebPack
ā€¢ https://www.eventbrite.com/e/react-js-foundation-
hands-on-workshop-tickets-27743432353
React App (MyWebPage.html)
<!ā€“ The core React library -->
<script src="https://fb.me/react-15.0.0-rc.2.js"></script>
<!ā€“ The ReactDOM Library -->
<script src="https://fb.me/react-dom-15.0.0-rc.2.js">
</script>
<!ā€“ For transpiling ES6 code into ES5 code -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-
core/5.8.23/browser.min.js">
</script>
ReactJS ā€œHello Worldā€ (Old Style)
ā€¢ <body>
ā€¢ <div id="hello"></div>
ā€¢ <script type="text/babel">
ā€¢ var Hello = React.createClass({ // deprecated in 0.14.3
ā€¢ render: function () {
ā€¢ return ( <h1>Hello World</h1> );
ā€¢ }
ā€¢ });
ā€¢ ReactDOM.render(<Hello/>,
ā€¢ document.getElementById('hello'));
ā€¢ </script>
ā€¢ </body>
ReactJS ā€œHello Worldā€ (ES6 Class)
ā€¢ <div id="hello"></div>
ā€¢ <script type="text/babel">
ā€¢ class Hello extends React.Component { // recommended
ā€¢ constructor () {
ā€¢ super();
ā€¢ }
ā€¢ render() {
ā€¢ return <div>Hello World</div>
ā€¢ }
ā€¢ }
ā€¢ ReactDOM.render(<Hello/>,
ā€¢ document.getElementById('hello'));
ā€¢ </script>
The render() Method in ReactJS
ā€¢ Contains one top-level ā€œrootā€ element
ā€¢ a <div> is often the top-level element
ā€¢ render() is invoked when a state change occurs
ā€¢ NB: a <View> is the top-level element in React Native
Using ā€œPropsā€ in ReactJS
<div id="hello"></div>
ā€¢ <script type="text/babel">
ā€¢ var Hello = React.createClass({ // deprecated in 0.14.3
ā€¢ render: function () {
ā€¢ var name = this.props.name;
ā€¢
ā€¢ return ( <h2>Hello {name}</h2> );
ā€¢ }
ā€¢ });
ā€¢ ReactDOM.render(<Hello name="Dave"/>,
ā€¢ document.getElementById('hello'));
ā€¢ </script>
Property Types in ReactJS
propTypes contains properties and their types:
propTypes: {
width: React.PropTypes.number,
height: React.PropTypes.number
//other1: React.PropTypes.string,
//other2: React.PropTypes.array.isRequired,
},
Property Types and Validation
How to throw an error if any property is negative:
propTypes: {
width: function(props, propName, componentName) {
if(props[propName] < 0) {
throw new Error(propName+" cannot be negative");
}
}
},
The ā€œgetDefaultProps()ā€ Method
<div id="container"></div>
<script type="text/babel">
var Hello = React.createClass({
getDefaultProps: function () {
return { y : 456 }
},
render: function () {
return (
<h2>x = {this.props.x} y = {this.props.y} </h2>
);
}
});
ReactDOM.render(<Hello x={123}/>,
document.getElementById('container'));
</script>
Handling Mouse Events
class MouseOverButton extends React.Component {
// constructor ā€¦
render() {
console.log("rendering button...");
return (
<button onClick={this.update}>ClickMe</button>
);
}
update() {
console.log("inside update");
}
}
SVG in ReactJS (part 1)
<div id="mysvg"></div>
<script type="text/babel">
class MySVG extends React.Component {
constructor () {
super();
}
// more code in the next slideā€¦
SVG in ReactJS (part 2)
render() {
return (
<svg width="600" height="200">
<g transform="translate(50, 20)">
<rect x="10" y="10" width="160" height="80" fill="red"/>
</g>
</svg>
);
}
}
ReactDOM.render(<MySVG />,
document.getElementById("mysvg"));
</script>
Conditional Execution (1)
<div id="hello"></div>
<script type="text/babel">
class Hello1 extends React.Component {
render () {
return (
<h2>Hello World1</h2>
);
}
}
Conditional Execution (2)
class Hello2 extends React.Component {
render() {
return (
<h2>Hello World2</h2>
);
}
}
Conditional Execution (3)
ReactDOM.render(
<div>
{ Math.random() > 0.5 ? <Hello1 /> : <Hello2 />}
</div>,
document.getElementById('hello')
);
Working with Lists (1a)
class UserList extends React.Component {
render() {
return (
<ul>
<li>Sara</li>
<li>Dave</li>
<li>John</li>
<li>Sally</li>
</ul>
)
}
}
ReactDOM.render( <UserList/>,
document.getElementById('container')
)
Working with Lists (2a)
class UserList extends React.Component {
render() {
return (
<ul>
<ListOptions value="Sara" />
<ListOptions value="Dave" />
<ListOptions value="John" />
<ListOptions value="Sally" />
</ul>
)
}
}
Working with Lists (2b)
class ListOptions extends React.Component {
render() {
return (
<li>{this.props.value}</li>
)
}
}
ReactDOM.render( <UserList/>,
document.getElementById('container')
)
Sometimes we Need JavaScript Functions
ā€¢ Use map() to apply a function to an array of items:
a) Returns a new array with ā€˜transformedā€™ elements
b) You specify the function
ā€¢ Use filter() to return a subarray of items:
involves conditional logic (defined by you)
ā€¢ Other functions: merge(), flatten(), reduce(), ā€¦
ā€¢ NB: you can combine them via method chaining
The ā€˜mapā€™ and ā€˜filterā€™ Functions
var items = [1,2,3,4,5,6,7,8,9,10,11,
12,13,14,15,16,17,18,19,20];
var even = [], double = [];
even = items.filter(function(item) {
return item % 2 == 0;
});
console.log("even = "+even);
double = items.map(function(item) {
return item * 2;
});
console.log("double = "+double);
The ā€˜mapā€™ and ā€˜filterā€™ Functions
var items = [1,2,3,4,5,6,7,8,9,10];
var result1 = items.filter(function(item) { return item % 4 == 0; })
.map(function(item) { return item * 2; });
var result2 = items.map(function(item) { return item * 2; })
.filter(function(item) { return item % 4 == 0; })
console.log("result1 = "+result1);
console.log("result2 = "+result2);
Working with Lists (3a)
class UserList extends React.Component {
constructor() {
super();
this.userList = [ 'Sara', 'Dave', 'John', 'Sallyā€™];
}
render() {
return (
<div>
<ListOptions2 names={this.userList} />
</div>
)
}
}
Working with Lists (1)
class ListOptions2 extends React.Component {
render() {
return (
<ul>
{this.props.names.map(function(name) {
return (
<li key={name}>{name}</li>
)
})}
</ul>
)
}
}
Echoing User Input in ReactJS
class Echo extends React.Component {
constructor() {
super();
}
render() {
return (
<input type="text" onChange={this.handleChange} />
);
}
handleChange(e) {
console.log(e.target.value);
}
}
ReactDOM.render(<Echo />, document.getElementById("content"));
ReactJS: Lifecycle methods
Before/during/after component ā€˜mountingā€™:
componentWillMount: function() {
this.doSomething1();
},
componentShouldMount: function() {
this.doSomething2();
},
componentShouldUpdate: function() {
this.doSomething3();
},
componentDidMount: function() {
this.doSomething4();
},
componentWillUnmount: function() {
this.doSomething5();
},
ReactJS: Lifecycle methods
Consider the following scenario:
A Web page contains GSAP code to animate SVG elements
The SVG elements are dynamically generated
There is no static SVG content
Q: where do you place the GSAP code?
A: in the componentDidMount() method
Working with State (1a)
class MyInput extends React.Component {
constructor() {
super();
}
componentWillMount() {
this.state = {value: 'Hello There!'};
}
handleChange(event) {
this.setState({value: event.target.value});
console.log("value: "+this.state.value);
}
Working with State (1b)
render() {
var value = this.state.value;
return <input type="text" value={value}
onChange={this.handleChange} />;
}
}
ReactDOM.render(
<MyInput />,
document.getElementById('myinput')
);
Update List of Users (1)
class UserList extends React.Component {
constructor() {
super();
this.userList = ['Sara', 'Dave', 'John', 'Sallyā€™ ];
this.addUser = this.addUser.bind(this);
}
componentDidMount() {
this.setState({user: ""});
}
addUser() {
var user = this.refs.user.value;
//console.log("user = "+user);
this.setState({user: user});
this.userList.push(user);
}
Update List of Users (2)
render() {
return (
<div>
<ul>
<ListOptions options={this.userList} />
</ul>
<input ref="user" type="text" />
<button onClick={this.addUser}>Add User</button>
</div>
)
}
}
Update List of Users (3)
class ListOptions extends React.Component {
render() {
return (
<ul>
{this.props.options.map(function(option) { // options = userList
return (
<li key={option}>{option}</li>
)
})}
</ul>
)
}
}
ReactDOM.render( <ListOptions/>,
document.getElementById('containerā€™))
Working with JSON Data Files (1a)
ā€¢ class UserInfo extends React.Component {
ā€¢ constructor() {
ā€¢ super();
ā€¢ }
ā€¢ componentWillMount() {
ā€¢ this.state = { loading: true, error: null, data: null};
ā€¢ }
ā€¢
ā€¢ componentDidMount() {
ā€¢ this.props.promise.then(
ā€¢ value => this.setState({loading: false, data: value}),
ā€¢ error => this.setState({loading: false, error: error}));
ā€¢ }
Working with JSON Data Files (1b)
render() {
ā€¢ if (this.state.loading) {
ā€¢ return <span>Loading...</span>;
ā€¢ }
ā€¢ else if (this.state.error !== null) {
ā€¢ return <span>Error: {this.state.error.message}</span>;
ā€¢ }
ā€¢ else {
ā€¢ let empItems = this.state.data.map( emp => {
ā€¢ return <li key={emp.fname}>{emp.fname}</li>
ā€¢ })
ā€¢ return (
ā€¢ <div>
ā€¢ <ul>{empItems}</ul>
ā€¢ </div>
ā€¢ )
}}
Retrieving Github User Data (1)
ā€¢ class UserInfo extends React.Component {
ā€¢ constructor() {
ā€¢ super();
ā€¢ }
ā€¢ componentWillMount() {
ā€¢ this.state = { loading: true, error: null, data: null};
ā€¢ }
ā€¢
ā€¢ componentDidMount() {
ā€¢ this.props.promise.then(
ā€¢ value => this.setState({loading: false, data: value}),
ā€¢ error => this.setState({loading: false, error: error}));
ā€¢ }
Retrieving Github User Data (2)
render() {
if (this.state.loading) { return <span>Loading...</span>; }
else if (this.state.error !== null) {
return <span>Error: {this.state.error.message}</span>;
}
else {
var userInfo = this.state.data;
return (
<ul>
<li>Username: {userInfo.login} </li>
<li>Followers: {userInfo.followers} </li>
<li>Following: {userInfo.following} </li>
<li>Created at: {userInfo.created_at}</li>
</ul>
)
}}}
Retrieving Github User Data (3)
ReactDOM.render(
<UserInfo
promise={$.getJSON('https://api.github.com/users/ocampesato')} />,
document.getElementById("userinfo")
);
What about React Routing?
ā€¢ Routing: how to access different parts of an app
ā€¢ Static routing and Dynamic routing
ā€¢ http://rwhitmire.com/react-routify
ā€¢ ReactRouter v4 contains major changes:
https://github.com/ReactTraining/react-
router/blob/v4/README.md#v4-faq
Heroku and create-react-app (1)
https://github.com/facebookincubator/
a FB endorsed and supported way to build real React apps
Zero configuration deployment to Heroku:
https://blog.heroku.com/deploying-react-with-zero-
configuration
https://github.com/mars/create-react-app-buildpack#usage
Heroku and create-react-app (2)
ā€¢ npm install -g create-react-app
ā€¢ create-react-app my-app
ā€¢ cd my-app
ā€¢ git init
ā€¢ heroku create -b https://github.com/mars/create-react-
app-buildpack.git
ā€¢ git add .
ā€¢ git commit -m "react-create-app on Heroku"
ā€¢ git push heroku master
ā€¢ heroku open
Higher Order Components
ā€¢ Define functions that take a component as an argument
and then return a component
ā€¢ https://medium.com/javascript-inside/why-the-hipsters-
recompose-everything-23ac08748198#.ojvtuun57
ā€¢ Now letā€™s take a detour to ES6ā€¦.
What about ES6?
ā€¢ Arrow functions and let keyword
ā€¢ Block scopes
ā€¢ Classes and inheritance
ā€¢ Default parameters
ā€¢ Destructured assignment
ā€¢ Generators, Iterators, Maps, and Sets
ā€¢ Promises and Rest parameters
ā€¢ Spread operator
ā€¢ Template Literals
ES6 let and Arrow Functions
ā€¢ let square = x => x * x;
ā€¢ let add = (x, y) => x + y;
ā€¢ let pi = () => 3.1415;
ā€¢ console.log(square(8)); // 64
ā€¢ console.log(add(5, 9)); // 14
ā€¢ console.log(pi()); // 3.1415
ES6 Class Definition (part 1)
class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
}
calcArea() {
return this.height * this.width;
}
}
ā€¢ var r1 = new Rectangle(5,10);
ā€¢ var r2 = new Rectangle(25,15);
ES6 Class Definition (part 2)
ā€¢ console.log("r1 area = "+r1.calcArea());
ā€¢ console.log("r2 area = "+r2.calcArea());
ā€¢ Test this code here: http://babeljs.io/repl/
ā€¢ More Examples:
https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Classes
Browser Status for ES6
ā€¢ Modern IE: https://goo.gl/56n7IL
ā€¢ Mozilla: https://goo.gl/iSNDf9
ā€¢ Chrome: https://www.chromestatus.com/features#ES6
Other Useful ES6 Links
https://github.com/lukehoban/es6features
http://kangax.github.io/compat-table/es6/
https://dev.modern.ie/platform/status/?filter=f3f0000bf&search=es6
https://developer.mozilla.org/en-
US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_i
n_Mozilla
https://medium.com/@bojzi/overview-of-the-javascript-ecosystem-
8ec4a0b7a7be
Next weā€™ll discuss application stateā€¦.
Application State can be Complicated
ā€¢ Suppose a ReactJS has many components
ā€¢ What if state is required in multiple components?
ā€¢ Where is state maintained?
ā€¢ resembles a C++ class hierarchy a ā€œthickā€ base class allows for
easy access, but some things donā€™t belong in the base class
ā€¢ One solution: store state outside the app (Redux)
ReactJS + Flux (Facebook)
ā€¢ Flux is a pattern (Facebook)
ā€¢ unidirectional data flow
ā€¢ Many implementations of Flux are available
ā€¢ Redux is an implementation of Flux . . .
ReactJS + Redux (Facebook)
ā€¢ Redux is an implementation of Flux
ā€¢ the most popular implementation (at least 15 others)
ā€¢ Mobx (simpler alternative) and Alt
ā€¢ ā€œadvanced state managementā€
ā€¢ Actions, Dispatcher, reducer, and Store(s)
ā€¢ Reductor: Redux for Android
ReactJS + Redux (Facebook)
ā€¢ How Redux works:
ā€¢ Create a Redux store
ā€¢ Dispatcher passes Action and Store to Reducer
ā€¢ Reducer updates the Store
ā€¢ View is notified and updated accordingly
Redux versus Mobx
ā€¢ Redux: influenced by functional programming
ā€¢ Mobx: influenced by OOP and Reactive Programming
ā€¢ More detailed comparison of Redux and Mobx:
1) http://www.robinwieruch.de/redux-mobx-confusion
2)https://medium.com/@sanketsahu/if-not-redux-then-
what-fc433234f5b4#.38tus3hai
3) http://blog.bandwidth.com/using-react-js-for-front-end-
development
ReactJS + GraphQL (Facebook)
ā€¢ GraphQL: a server-side schema for graph-oriented data
ā€¢ Can ā€œwrapā€ NoSQL and relational stores
ā€¢ GraphQL server processes data requests from clients
ā€¢ Data is returned to client apps
ā€¢ http://githubengineering.com/the-github-graphql-api/
ā€¢ NB: GraphQL does not need Relay (but Relay needs GraphQL)
GraphQL versus REST
ā€¢ GraphQL is a ā€œfiner-grainedā€ alternative to REST
ā€¢ REST is all-or-nothing: an ā€œentityā€ is returned
ā€¢ GraphQL returns a subset of elements of an ā€œentityā€
ā€¢ Falcor from Netflix: GraphQL alternative (without a schema)
GraphQL: What it isnā€™t
ā€¢ GQL does not dictate a server language
ā€¢ GQL does not dictate a storage/back-end
ā€¢ GQL is a query language without a database
GraphQL: What Does it Do?
ā€¢ It exposes a single endpoint
ā€¢ the endpoint parses and executes a query
ā€¢ The query executes over a type system
ā€¢ the type system is defined in the application server
ā€¢ the type system is available via introspection (a GQL API)
GraphQL Server Structure
GraphQL servers have three components:
ā€¢ 1) GraphQL ā€œcoreā€ (JavaScript and other languages)
ā€¢ 2) Type Definitions (maps app code to internal system)
ā€¢ 3) Application code (business logic)
GraphQL Core: Five Components
ā€¢ 1) Frontend lexer/parser: an AST [Relay uses parser]
ā€¢ 2) Type System: GraphQLObjectType (a class)
ā€¢ 3) Introspection: for querying types
ā€¢ 4) Validation: is a query valid in the appā€™s schema?
ā€¢ 5) Execution: manage query execution (via the AST)
The GraphiQL IDE
ā€¢ https://github.com/skevy/graphiql-
app/blob/master/README.md
ā€¢ https://github.com/skevy/graphiql-app/releases
ā€¢ OSX: brew cask install graphiql
GraphQL Queries (Interfaces)
ā€¢ interface Employee {
ā€¢ id: String!
ā€¢ fname: String
ā€¢ lname: String
ā€¢ }
ā€¢
ā€¢ type Query {
ā€¢ emp: Employee
ā€¢ }
GraphQL Queries
ā€¢ GraphQL Query:
ā€¢ {
ā€¢ emp {
ā€¢ fname
ā€¢ }
ā€¢ }
ā€¢ Response data:
ā€¢ {
ā€¢ "data": [{
ā€¢ "emp": {
ā€¢ "fname": "John"
ā€¢ }
ā€¢ }]
ā€¢ }
GraphQL Queries
ā€¢ query EmpNameQuery {
ā€¢ emp {
ā€¢ fname
ā€¢ lname
ā€¢ }
ā€¢ }
ā€¢ The result of the preceding query is here:
ā€¢ {
ā€¢ "data": [{
ā€¢ "emp": {
ā€¢ "fname": "John",
ā€¢ "lname": "Smith"
ā€¢ }
ā€¢ }]
ā€¢ }
GraphQL Websites
ā€¢ Apollo: http://www.apollostack.com/
ā€œconsolidatesā€ data (removes duplicates in a tree)
ā€¢ Reindex: https://www.reindex.io/blog/redux-and-
relay
ā€¢ Scaphold: scaphold.io
ā€¢ Upcoming SF conference: http://graphqlsummit.com/
GraphQL Websites
ā€¢ Apollo: http://www.apollostack.com/
ā€œconsolidatesā€ data (removes duplicates in a tree)
ā€¢ Reindex: https://www.reindex.io/blog/redux-and-relay
ā€¢ Scaphold: https://scaphold.io/#/
ā€¢ GraphiQL: https://github.com/skevy/graphiql-app
ā€¢ GraphQL conference: http://graphqlsummit.com/
ReactJS + Relay (Facebook)
ā€¢ Relay: a ā€œwrapperā€ around client-side components
ā€¢ Data requests from a component ā€œgo throughā€ Relay
ā€¢ Relay sends data requests to a GraphQL server
ā€¢ Data is returned to client application
ā€¢ Data is displayed according to application code/logic
MERN: Mongo/Express/ReactJS/NodeJS
ā€¢ http://mern.io/
ā€¢ MERN starter app:
ā€¢ git clone https://github.com/Hashnode/mern-starter.git
ā€¢ cd mern-starter
ā€¢ npm install
ā€¢ npm start
ā€¢ MERN CLI:
ā€¢ [sudo] npm install -g mern-cli
ā€¢ mern init myApp
ā€¢ cd myApp
ā€¢ npm install
ā€¢ npm start
What is React Native? (Facebook)
ā€¢ Facebook toolkit for cross-platform native mobile apps
ā€¢ https://facebook.github.io/react-native/
ā€¢ You write custom JSX code for Android and iOS
ā€¢ Update contents of index.android.js and index.ios.js
ā€¢ Invoke react-native from command line
ā€¢ Update cycle: Mobile app is updated via ā€œhot reloadingā€
React Native Components
ā€¢ https://github.com/react-native-community/react-native-elements
ā€¢ Buttons
ā€¢ Icons
ā€¢ Social Icons / Buttons
ā€¢ Side Menu
ā€¢ Form Elements
ā€¢ Search Bar
ā€¢ ButtonGroup
ā€¢ Checkboxes
ā€¢ List Element
ā€¢ Linked List Element
ā€¢ Cross Platform Tab Bar
ā€¢ HTML style headings (h1, h2, etc...)
ā€¢ Card component
ā€¢ Pricing Component
React Native Installation
ā€¢ iOS apps: make sure youā€™ve installed Xcode
ā€¢ Android apps: install Java/Android/NDK:
set JAVA_HOME, ANDROID_HOME, and NDK_HOME
ā€¢ Now install react-native:
[sudo] npm install ā€“g react-native
ā€¢ Create an application:
react-native new FirstApp
Start an application: react-native run-android
More Stuff About React Native
ā€¢ Top-level element in render() must be a <View> element
ā€¢ You can create custom native components (Android&iOS)
ā€¢ Supports Flux/Redux/Relay/GraphQL
ā€¢ React Native with Redux:
https://github.com/ReactConvention/react-native-redux-
starter-kit
React Native IDEs/Toolkits
IDES: Deco (open source) and XDE (from Exponent)
Very good ā€œStarter kitsā€ (with lots of components):
ignite: https://infinite.red/ignite
nativebase: https://github.com/GeekyAnts/NativeBase
react-native ble: https://github.com/Polidea/react-native-
ble-plx
react-native-bg-geo:
https://github.com/transistorsoft/react-native-background-
geolocation
React Native IDEs/Toolkits
reactpack: https://github.com/olahol/reactpack
heatpack: https://github.com/olahol/reactpack
create-react-app: https://github.com/facebookincubator/
fb testing tools:
https://facebook.github.io/react/docs/test-utils.html
enzyme:
https://medium.com/airbnb-engineering/enzyme-javascript-
testing-utilities-for-react-a417e5e5090f
Some Useful Tools/IDEs
ā€¢ Select an IDE:
+WebStorm 10: free 30-day trial ($49/year)
+Visual Studio Code (free)
+ Atom (free) with atom-TypeScript extension
ā€¢ Command Line Tools:
+ npm, npmjs, gulp, grunt (older), broccoli,
+ webpack, browserify (older), jspm+systemjs
https://github.com/addyosmani/es6-tools
Useful Technologies to Learn
ā€¢ Main features of ES6 (and methods in ECMA5)
ā€¢ Sass/Bootstrap 4 (previously: less)
ā€¢ https://react-bootstrap.github.io/
ā€¢ D3.js for Data Visualization
ā€¢ React Native (=ReactJS for Native Mobile)
ā€¢ https://egghead.io/react-redux-cheatsheets
Recent/Upcoming Books and Training
1) HTML5 Canvas and CSS3 Graphics (2013)
2) jQuery, CSS3, and HTML5 for Mobile (2013)
3) HTML5 Pocket Primer (2013)
4) jQuery Pocket Primer (2013)
5) HTML5 Mobile Pocket Primer (2014)
6) D3 Pocket Primer (2015)
7) Python Pocket Primer (2015)
8) SVG Pocket Primer (2016)
9) CSS3 Pocket Primer (2016)
10) Angular 2 Pocket Primer (2017)

More Related Content

What's hot

Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners Varun Raj
Ā 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JSBethmi Gunasekara
Ā 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.jsDoug Neiner
Ā 
Java Script ppt
Java Script pptJava Script ppt
Java Script pptPriya Goyal
Ā 
React js programming concept
React js programming conceptReact js programming concept
React js programming conceptTariqul islam
Ā 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript ProgrammingSehwan Noh
Ā 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to ReactRob Quick
Ā 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.jsRitesh Mehrotra
Ā 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JSArno Lordkronos
Ā 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux IntroductionNikolaus Graf
Ā 
What is component in reactjs
What is component in reactjsWhat is component in reactjs
What is component in reactjsmanojbkalla
Ā 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMJimit Shah
Ā 
React Router: React Meetup XXL
React Router: React Meetup XXLReact Router: React Meetup XXL
React Router: React Meetup XXLRob Gietema
Ā 

What's hot (20)

Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
Ā 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
Ā 
React js
React jsReact js
React js
Ā 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
Ā 
React hooks
React hooksReact hooks
React hooks
Ā 
Reactjs
ReactjsReactjs
Reactjs
Ā 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
Ā 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
Ā 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Ā 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
Ā 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
Ā 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
Ā 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
Ā 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
Ā 
What is component in reactjs
What is component in reactjsWhat is component in reactjs
What is component in reactjs
Ā 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
Ā 
React Router: React Meetup XXL
React Router: React Meetup XXLReact Router: React Meetup XXL
React Router: React Meetup XXL
Ā 
ReactJS
ReactJSReactJS
ReactJS
Ā 
ReactJS
ReactJSReactJS
ReactJS
Ā 
WEB DEVELOPMENT USING REACT JS
 WEB DEVELOPMENT USING REACT JS WEB DEVELOPMENT USING REACT JS
WEB DEVELOPMENT USING REACT JS
Ā 

Viewers also liked

Viewers also liked (11)

ReactJs presentation
ReactJs presentationReactJs presentation
ReactJs presentation
Ā 
Express js clean-controller
Express js clean-controllerExpress js clean-controller
Express js clean-controller
Ā 
Intro to ReactJS
Intro to ReactJSIntro to ReactJS
Intro to ReactJS
Ā 
Express JS
Express JSExpress JS
Express JS
Ā 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
Ā 
React + Redux for Web Developers
React + Redux for Web DevelopersReact + Redux for Web Developers
React + Redux for Web Developers
Ā 
Architecting large Node.js applications
Architecting large Node.js applicationsArchitecting large Node.js applications
Architecting large Node.js applications
Ā 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
Ā 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesome
Ā 
Express JS
Express JSExpress JS
Express JS
Ā 
Express js
Express jsExpress js
Express js
Ā 

Similar to React js

ReactJS for Beginners
ReactJS for BeginnersReactJS for Beginners
ReactJS for BeginnersOswald Campesato
Ā 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)Jo Cranford
Ā 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationAndrew Rota
Ā 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React TogetherSebastian Pederiva
Ā 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today Nitin Tyagi
Ā 
Overview Of Lift Framework
Overview Of Lift FrameworkOverview Of Lift Framework
Overview Of Lift FrameworkXebia IT Architects
Ā 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkIndicThreads
Ā 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Frameworkvhazrati
Ā 
20171108 PDN HOL React Basics
20171108 PDN HOL React Basics20171108 PDN HOL React Basics
20171108 PDN HOL React BasicsRich Ross
Ā 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick Lee
Ā 
2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & Webpack2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & WebpackCodifly
Ā 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Elyse Kolker Gordon
Ā 
React.js: You deserve to know about it
React.js: You deserve to know about itReact.js: You deserve to know about it
React.js: You deserve to know about itAnderson Aguiar
Ā 
Building complex User Interfaces with Sitecore and React
Building complex User Interfaces with Sitecore and ReactBuilding complex User Interfaces with Sitecore and React
Building complex User Interfaces with Sitecore and ReactJonne Kats
Ā 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just RubyMarco Otte-Witte
Ā 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
Ā 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptxDayNightGaMiNg
Ā 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Foreverstephskardal
Ā 

Similar to React js (20)

ReactJS for Beginners
ReactJS for BeginnersReactJS for Beginners
ReactJS for Beginners
Ā 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)
Ā 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
Ā 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React Together
Ā 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
Ā 
Universal JavaScript
Universal JavaScriptUniversal JavaScript
Universal JavaScript
Ā 
Overview Of Lift Framework
Overview Of Lift FrameworkOverview Of Lift Framework
Overview Of Lift Framework
Ā 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
Ā 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
Ā 
20171108 PDN HOL React Basics
20171108 PDN HOL React Basics20171108 PDN HOL React Basics
20171108 PDN HOL React Basics
Ā 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
Ā 
2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & Webpack2018 05-16 Evolving Technologies: React, Babel & Webpack
2018 05-16 Evolving Technologies: React, Babel & Webpack
Ā 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017
Ā 
React.js: You deserve to know about it
React.js: You deserve to know about itReact.js: You deserve to know about it
React.js: You deserve to know about it
Ā 
Building complex User Interfaces with Sitecore and React
Building complex User Interfaces with Sitecore and ReactBuilding complex User Interfaces with Sitecore and React
Building complex User Interfaces with Sitecore and React
Ā 
ReactJS.ppt
ReactJS.pptReactJS.ppt
ReactJS.ppt
Ā 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
Ā 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Ā 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
Ā 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
Ā 

More from Oswald Campesato

Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)Oswald Campesato
Ā 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasOswald Campesato
Ā 
Introduction to Deep Learning
Introduction to Deep LearningIntroduction to Deep Learning
Introduction to Deep LearningOswald Campesato
Ā 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2Oswald Campesato
Ā 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2Oswald Campesato
Ā 
"An Introduction to AI and Deep Learning"
"An Introduction to AI and Deep Learning""An Introduction to AI and Deep Learning"
"An Introduction to AI and Deep Learning"Oswald Campesato
Ā 
Introduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and TensorflowIntroduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and TensorflowOswald Campesato
Ā 
Introduction to Deep Learning for Non-Programmers
Introduction to Deep Learning for Non-ProgrammersIntroduction to Deep Learning for Non-Programmers
Introduction to Deep Learning for Non-ProgrammersOswald Campesato
Ā 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your BrowserOswald Campesato
Ā 
Deep Learning in Your Browser
Deep Learning in Your BrowserDeep Learning in Your Browser
Deep Learning in Your BrowserOswald Campesato
Ā 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlowOswald Campesato
Ā 
Introduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlowIntroduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlowOswald Campesato
Ā 
Intro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsIntro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsOswald Campesato
Ā 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlowOswald Campesato
Ā 
Introduction to Deep Learning and Tensorflow
Introduction to Deep Learning and TensorflowIntroduction to Deep Learning and Tensorflow
Introduction to Deep Learning and TensorflowOswald Campesato
Ā 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and SparkOswald Campesato
Ā 
Deep Learning in your Browser: powered by WebGL
Deep Learning in your Browser: powered by WebGLDeep Learning in your Browser: powered by WebGL
Deep Learning in your Browser: powered by WebGLOswald Campesato
Ā 
Deep Learning, Keras, and TensorFlow
Deep Learning, Keras, and TensorFlowDeep Learning, Keras, and TensorFlow
Deep Learning, Keras, and TensorFlowOswald Campesato
Ā 
C++ and Deep Learning
C++ and Deep LearningC++ and Deep Learning
C++ and Deep LearningOswald Campesato
Ā 

More from Oswald Campesato (20)

Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)
Ā 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and Keras
Ā 
Introduction to Deep Learning
Introduction to Deep LearningIntroduction to Deep Learning
Introduction to Deep Learning
Ā 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
Ā 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
Ā 
"An Introduction to AI and Deep Learning"
"An Introduction to AI and Deep Learning""An Introduction to AI and Deep Learning"
"An Introduction to AI and Deep Learning"
Ā 
H2 o berkeleydltf
H2 o berkeleydltfH2 o berkeleydltf
H2 o berkeleydltf
Ā 
Introduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and TensorflowIntroduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and Tensorflow
Ā 
Introduction to Deep Learning for Non-Programmers
Introduction to Deep Learning for Non-ProgrammersIntroduction to Deep Learning for Non-Programmers
Introduction to Deep Learning for Non-Programmers
Ā 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your Browser
Ā 
Deep Learning in Your Browser
Deep Learning in Your BrowserDeep Learning in Your Browser
Deep Learning in Your Browser
Ā 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
Ā 
Introduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlowIntroduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlow
Ā 
Intro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsIntro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.js
Ā 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
Ā 
Introduction to Deep Learning and Tensorflow
Introduction to Deep Learning and TensorflowIntroduction to Deep Learning and Tensorflow
Introduction to Deep Learning and Tensorflow
Ā 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and Spark
Ā 
Deep Learning in your Browser: powered by WebGL
Deep Learning in your Browser: powered by WebGLDeep Learning in your Browser: powered by WebGL
Deep Learning in your Browser: powered by WebGL
Ā 
Deep Learning, Keras, and TensorFlow
Deep Learning, Keras, and TensorFlowDeep Learning, Keras, and TensorFlow
Deep Learning, Keras, and TensorFlow
Ā 
C++ and Deep Learning
C++ and Deep LearningC++ and Deep Learning
C++ and Deep Learning
Ā 

Recently uploaded

call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøDelhi Call girls
Ā 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp KrisztiƔn
Ā 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
Ā 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
Ā 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
Ā 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
Ā 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
Ā 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
Ā 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
Ā 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
Ā 
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...Steffen Staab
Ā 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
Ā 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
Ā 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
Ā 
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøDelhi Call girls
Ā 
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE9953056974 Low Rate Call Girls In Saket, Delhi NCR
Ā 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
Ā 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
Ā 
Chinsurah Escorts ā˜Žļø8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ā˜Žļø8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ā˜Žļø8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ā˜Žļø8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
Ā 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
Ā 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
Ā 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
Ā 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Ā 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
Ā 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
Ā 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
Ā 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
Ā 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
Ā 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
Ā 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
Ā 
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data SpacesĀ - and Epistemic Querying of RDF-...
Ā 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
Ā 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
Ā 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
Ā 
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļøcall girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
call girls in Vaishali (Ghaziabad) šŸ” >ą¼’8448380779 šŸ” genuine Escort Service šŸ”āœ”ļøāœ”ļø
Ā 
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )šŸ” 9953056974šŸ”(=)/CALL GIRLS SERVICE
Ā 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
Ā 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
Ā 
Chinsurah Escorts ā˜Žļø8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ā˜Žļø8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ā˜Žļø8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ā˜Žļø8617697112 Starting From 5K to 15K High Profile Escorts ...
Ā 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
Ā 

React js

  • 1. ReactJS for Beginners Oswald Campesato Consultant/Training: www.iquarkt.com ocampesato@yahoo.com
  • 2. What is ReactJS? ā€¢ Library for Web Apps (from Facebook) ā€¢ Provides the ā€œVā€ in ā€œMVCā€ ā€¢ component-based architecture ā€¢ ES6/JSX (HTML embedded in JavaScript) ā€¢ 400 components available: https://github.com/brillout/awesome-react-components
  • 3. Advantages of ReactJS ā€¢ highly efficient ā€¢ easier to write Javascript via JSX ā€¢ out-of-the-box developer tools ā€¢ very good for SEO ā€¢ easy to write UI test cases ā€¢ http://www.pro-tekconsulting.com/blog/advantages- disadvantages-of-react-js/
  • 4. Disadvantages of ReactJS ā€¢ ReactJS is only a view layer ā€¢ ReactJS into an MVC framework requires configuration ā€¢ learning curve for beginners who are new to web development ā€¢ Scaffolding is usually needed for transpilation
  • 5. What are Transpilers? ā€¢ They convert code from one language to another ā€¢ Babel (formerly 6to5): +converts ES6 (some ES7) to ECMA5 + appears to be the de facto standard ā€¢ Traceur (Google): + converts ES6 to ECMA5 + used by Angular 2 NOTE: JSX is transpiled by ECMA5
  • 6. Typical Set-up Tools ā€¢ Node and npm (installing JS dependencies) ā€¢ Babel (in HTML Web pages) ā€¢ Webpack (highly recommended) ā€¢ NB: you can use Gulp instead of WebPack ā€¢ https://www.eventbrite.com/e/react-js-foundation- hands-on-workshop-tickets-27743432353
  • 7. React App (MyWebPage.html) <!ā€“ The core React library --> <script src="https://fb.me/react-15.0.0-rc.2.js"></script> <!ā€“ The ReactDOM Library --> <script src="https://fb.me/react-dom-15.0.0-rc.2.js"> </script> <!ā€“ For transpiling ES6 code into ES5 code --> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel- core/5.8.23/browser.min.js"> </script>
  • 8. ReactJS ā€œHello Worldā€ (Old Style) ā€¢ <body> ā€¢ <div id="hello"></div> ā€¢ <script type="text/babel"> ā€¢ var Hello = React.createClass({ // deprecated in 0.14.3 ā€¢ render: function () { ā€¢ return ( <h1>Hello World</h1> ); ā€¢ } ā€¢ }); ā€¢ ReactDOM.render(<Hello/>, ā€¢ document.getElementById('hello')); ā€¢ </script> ā€¢ </body>
  • 9. ReactJS ā€œHello Worldā€ (ES6 Class) ā€¢ <div id="hello"></div> ā€¢ <script type="text/babel"> ā€¢ class Hello extends React.Component { // recommended ā€¢ constructor () { ā€¢ super(); ā€¢ } ā€¢ render() { ā€¢ return <div>Hello World</div> ā€¢ } ā€¢ } ā€¢ ReactDOM.render(<Hello/>, ā€¢ document.getElementById('hello')); ā€¢ </script>
  • 10. The render() Method in ReactJS ā€¢ Contains one top-level ā€œrootā€ element ā€¢ a <div> is often the top-level element ā€¢ render() is invoked when a state change occurs ā€¢ NB: a <View> is the top-level element in React Native
  • 11. Using ā€œPropsā€ in ReactJS <div id="hello"></div> ā€¢ <script type="text/babel"> ā€¢ var Hello = React.createClass({ // deprecated in 0.14.3 ā€¢ render: function () { ā€¢ var name = this.props.name; ā€¢ ā€¢ return ( <h2>Hello {name}</h2> ); ā€¢ } ā€¢ }); ā€¢ ReactDOM.render(<Hello name="Dave"/>, ā€¢ document.getElementById('hello')); ā€¢ </script>
  • 12. Property Types in ReactJS propTypes contains properties and their types: propTypes: { width: React.PropTypes.number, height: React.PropTypes.number //other1: React.PropTypes.string, //other2: React.PropTypes.array.isRequired, },
  • 13. Property Types and Validation How to throw an error if any property is negative: propTypes: { width: function(props, propName, componentName) { if(props[propName] < 0) { throw new Error(propName+" cannot be negative"); } } },
  • 14. The ā€œgetDefaultProps()ā€ Method <div id="container"></div> <script type="text/babel"> var Hello = React.createClass({ getDefaultProps: function () { return { y : 456 } }, render: function () { return ( <h2>x = {this.props.x} y = {this.props.y} </h2> ); } }); ReactDOM.render(<Hello x={123}/>, document.getElementById('container')); </script>
  • 15. Handling Mouse Events class MouseOverButton extends React.Component { // constructor ā€¦ render() { console.log("rendering button..."); return ( <button onClick={this.update}>ClickMe</button> ); } update() { console.log("inside update"); } }
  • 16. SVG in ReactJS (part 1) <div id="mysvg"></div> <script type="text/babel"> class MySVG extends React.Component { constructor () { super(); } // more code in the next slideā€¦
  • 17. SVG in ReactJS (part 2) render() { return ( <svg width="600" height="200"> <g transform="translate(50, 20)"> <rect x="10" y="10" width="160" height="80" fill="red"/> </g> </svg> ); } } ReactDOM.render(<MySVG />, document.getElementById("mysvg")); </script>
  • 18. Conditional Execution (1) <div id="hello"></div> <script type="text/babel"> class Hello1 extends React.Component { render () { return ( <h2>Hello World1</h2> ); } }
  • 19. Conditional Execution (2) class Hello2 extends React.Component { render() { return ( <h2>Hello World2</h2> ); } }
  • 20. Conditional Execution (3) ReactDOM.render( <div> { Math.random() > 0.5 ? <Hello1 /> : <Hello2 />} </div>, document.getElementById('hello') );
  • 21. Working with Lists (1a) class UserList extends React.Component { render() { return ( <ul> <li>Sara</li> <li>Dave</li> <li>John</li> <li>Sally</li> </ul> ) } } ReactDOM.render( <UserList/>, document.getElementById('container') )
  • 22. Working with Lists (2a) class UserList extends React.Component { render() { return ( <ul> <ListOptions value="Sara" /> <ListOptions value="Dave" /> <ListOptions value="John" /> <ListOptions value="Sally" /> </ul> ) } }
  • 23. Working with Lists (2b) class ListOptions extends React.Component { render() { return ( <li>{this.props.value}</li> ) } } ReactDOM.render( <UserList/>, document.getElementById('container') )
  • 24. Sometimes we Need JavaScript Functions ā€¢ Use map() to apply a function to an array of items: a) Returns a new array with ā€˜transformedā€™ elements b) You specify the function ā€¢ Use filter() to return a subarray of items: involves conditional logic (defined by you) ā€¢ Other functions: merge(), flatten(), reduce(), ā€¦ ā€¢ NB: you can combine them via method chaining
  • 25. The ā€˜mapā€™ and ā€˜filterā€™ Functions var items = [1,2,3,4,5,6,7,8,9,10,11, 12,13,14,15,16,17,18,19,20]; var even = [], double = []; even = items.filter(function(item) { return item % 2 == 0; }); console.log("even = "+even); double = items.map(function(item) { return item * 2; }); console.log("double = "+double);
  • 26. The ā€˜mapā€™ and ā€˜filterā€™ Functions var items = [1,2,3,4,5,6,7,8,9,10]; var result1 = items.filter(function(item) { return item % 4 == 0; }) .map(function(item) { return item * 2; }); var result2 = items.map(function(item) { return item * 2; }) .filter(function(item) { return item % 4 == 0; }) console.log("result1 = "+result1); console.log("result2 = "+result2);
  • 27. Working with Lists (3a) class UserList extends React.Component { constructor() { super(); this.userList = [ 'Sara', 'Dave', 'John', 'Sallyā€™]; } render() { return ( <div> <ListOptions2 names={this.userList} /> </div> ) } }
  • 28. Working with Lists (1) class ListOptions2 extends React.Component { render() { return ( <ul> {this.props.names.map(function(name) { return ( <li key={name}>{name}</li> ) })} </ul> ) } }
  • 29. Echoing User Input in ReactJS class Echo extends React.Component { constructor() { super(); } render() { return ( <input type="text" onChange={this.handleChange} /> ); } handleChange(e) { console.log(e.target.value); } } ReactDOM.render(<Echo />, document.getElementById("content"));
  • 30. ReactJS: Lifecycle methods Before/during/after component ā€˜mountingā€™: componentWillMount: function() { this.doSomething1(); }, componentShouldMount: function() { this.doSomething2(); }, componentShouldUpdate: function() { this.doSomething3(); }, componentDidMount: function() { this.doSomething4(); }, componentWillUnmount: function() { this.doSomething5(); },
  • 31. ReactJS: Lifecycle methods Consider the following scenario: A Web page contains GSAP code to animate SVG elements The SVG elements are dynamically generated There is no static SVG content Q: where do you place the GSAP code? A: in the componentDidMount() method
  • 32. Working with State (1a) class MyInput extends React.Component { constructor() { super(); } componentWillMount() { this.state = {value: 'Hello There!'}; } handleChange(event) { this.setState({value: event.target.value}); console.log("value: "+this.state.value); }
  • 33. Working with State (1b) render() { var value = this.state.value; return <input type="text" value={value} onChange={this.handleChange} />; } } ReactDOM.render( <MyInput />, document.getElementById('myinput') );
  • 34. Update List of Users (1) class UserList extends React.Component { constructor() { super(); this.userList = ['Sara', 'Dave', 'John', 'Sallyā€™ ]; this.addUser = this.addUser.bind(this); } componentDidMount() { this.setState({user: ""}); } addUser() { var user = this.refs.user.value; //console.log("user = "+user); this.setState({user: user}); this.userList.push(user); }
  • 35. Update List of Users (2) render() { return ( <div> <ul> <ListOptions options={this.userList} /> </ul> <input ref="user" type="text" /> <button onClick={this.addUser}>Add User</button> </div> ) } }
  • 36. Update List of Users (3) class ListOptions extends React.Component { render() { return ( <ul> {this.props.options.map(function(option) { // options = userList return ( <li key={option}>{option}</li> ) })} </ul> ) } } ReactDOM.render( <ListOptions/>, document.getElementById('containerā€™))
  • 37. Working with JSON Data Files (1a) ā€¢ class UserInfo extends React.Component { ā€¢ constructor() { ā€¢ super(); ā€¢ } ā€¢ componentWillMount() { ā€¢ this.state = { loading: true, error: null, data: null}; ā€¢ } ā€¢ ā€¢ componentDidMount() { ā€¢ this.props.promise.then( ā€¢ value => this.setState({loading: false, data: value}), ā€¢ error => this.setState({loading: false, error: error})); ā€¢ }
  • 38. Working with JSON Data Files (1b) render() { ā€¢ if (this.state.loading) { ā€¢ return <span>Loading...</span>; ā€¢ } ā€¢ else if (this.state.error !== null) { ā€¢ return <span>Error: {this.state.error.message}</span>; ā€¢ } ā€¢ else { ā€¢ let empItems = this.state.data.map( emp => { ā€¢ return <li key={emp.fname}>{emp.fname}</li> ā€¢ }) ā€¢ return ( ā€¢ <div> ā€¢ <ul>{empItems}</ul> ā€¢ </div> ā€¢ ) }}
  • 39. Retrieving Github User Data (1) ā€¢ class UserInfo extends React.Component { ā€¢ constructor() { ā€¢ super(); ā€¢ } ā€¢ componentWillMount() { ā€¢ this.state = { loading: true, error: null, data: null}; ā€¢ } ā€¢ ā€¢ componentDidMount() { ā€¢ this.props.promise.then( ā€¢ value => this.setState({loading: false, data: value}), ā€¢ error => this.setState({loading: false, error: error})); ā€¢ }
  • 40. Retrieving Github User Data (2) render() { if (this.state.loading) { return <span>Loading...</span>; } else if (this.state.error !== null) { return <span>Error: {this.state.error.message}</span>; } else { var userInfo = this.state.data; return ( <ul> <li>Username: {userInfo.login} </li> <li>Followers: {userInfo.followers} </li> <li>Following: {userInfo.following} </li> <li>Created at: {userInfo.created_at}</li> </ul> ) }}}
  • 41. Retrieving Github User Data (3) ReactDOM.render( <UserInfo promise={$.getJSON('https://api.github.com/users/ocampesato')} />, document.getElementById("userinfo") );
  • 42. What about React Routing? ā€¢ Routing: how to access different parts of an app ā€¢ Static routing and Dynamic routing ā€¢ http://rwhitmire.com/react-routify ā€¢ ReactRouter v4 contains major changes: https://github.com/ReactTraining/react- router/blob/v4/README.md#v4-faq
  • 43. Heroku and create-react-app (1) https://github.com/facebookincubator/ a FB endorsed and supported way to build real React apps Zero configuration deployment to Heroku: https://blog.heroku.com/deploying-react-with-zero- configuration https://github.com/mars/create-react-app-buildpack#usage
  • 44. Heroku and create-react-app (2) ā€¢ npm install -g create-react-app ā€¢ create-react-app my-app ā€¢ cd my-app ā€¢ git init ā€¢ heroku create -b https://github.com/mars/create-react- app-buildpack.git ā€¢ git add . ā€¢ git commit -m "react-create-app on Heroku" ā€¢ git push heroku master ā€¢ heroku open
  • 45. Higher Order Components ā€¢ Define functions that take a component as an argument and then return a component ā€¢ https://medium.com/javascript-inside/why-the-hipsters- recompose-everything-23ac08748198#.ojvtuun57 ā€¢ Now letā€™s take a detour to ES6ā€¦.
  • 46. What about ES6? ā€¢ Arrow functions and let keyword ā€¢ Block scopes ā€¢ Classes and inheritance ā€¢ Default parameters ā€¢ Destructured assignment ā€¢ Generators, Iterators, Maps, and Sets ā€¢ Promises and Rest parameters ā€¢ Spread operator ā€¢ Template Literals
  • 47. ES6 let and Arrow Functions ā€¢ let square = x => x * x; ā€¢ let add = (x, y) => x + y; ā€¢ let pi = () => 3.1415; ā€¢ console.log(square(8)); // 64 ā€¢ console.log(add(5, 9)); // 14 ā€¢ console.log(pi()); // 3.1415
  • 48. ES6 Class Definition (part 1) class Rectangle { constructor(height, width) { this.height = height; this.width = width; } calcArea() { return this.height * this.width; } } ā€¢ var r1 = new Rectangle(5,10); ā€¢ var r2 = new Rectangle(25,15);
  • 49. ES6 Class Definition (part 2) ā€¢ console.log("r1 area = "+r1.calcArea()); ā€¢ console.log("r2 area = "+r2.calcArea()); ā€¢ Test this code here: http://babeljs.io/repl/ ā€¢ More Examples: https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Classes
  • 50. Browser Status for ES6 ā€¢ Modern IE: https://goo.gl/56n7IL ā€¢ Mozilla: https://goo.gl/iSNDf9 ā€¢ Chrome: https://www.chromestatus.com/features#ES6
  • 51. Other Useful ES6 Links https://github.com/lukehoban/es6features http://kangax.github.io/compat-table/es6/ https://dev.modern.ie/platform/status/?filter=f3f0000bf&search=es6 https://developer.mozilla.org/en- US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_i n_Mozilla https://medium.com/@bojzi/overview-of-the-javascript-ecosystem- 8ec4a0b7a7be Next weā€™ll discuss application stateā€¦.
  • 52. Application State can be Complicated ā€¢ Suppose a ReactJS has many components ā€¢ What if state is required in multiple components? ā€¢ Where is state maintained? ā€¢ resembles a C++ class hierarchy a ā€œthickā€ base class allows for easy access, but some things donā€™t belong in the base class ā€¢ One solution: store state outside the app (Redux)
  • 53. ReactJS + Flux (Facebook) ā€¢ Flux is a pattern (Facebook) ā€¢ unidirectional data flow ā€¢ Many implementations of Flux are available ā€¢ Redux is an implementation of Flux . . .
  • 54. ReactJS + Redux (Facebook) ā€¢ Redux is an implementation of Flux ā€¢ the most popular implementation (at least 15 others) ā€¢ Mobx (simpler alternative) and Alt ā€¢ ā€œadvanced state managementā€ ā€¢ Actions, Dispatcher, reducer, and Store(s) ā€¢ Reductor: Redux for Android
  • 55. ReactJS + Redux (Facebook) ā€¢ How Redux works: ā€¢ Create a Redux store ā€¢ Dispatcher passes Action and Store to Reducer ā€¢ Reducer updates the Store ā€¢ View is notified and updated accordingly
  • 56. Redux versus Mobx ā€¢ Redux: influenced by functional programming ā€¢ Mobx: influenced by OOP and Reactive Programming ā€¢ More detailed comparison of Redux and Mobx: 1) http://www.robinwieruch.de/redux-mobx-confusion 2)https://medium.com/@sanketsahu/if-not-redux-then- what-fc433234f5b4#.38tus3hai 3) http://blog.bandwidth.com/using-react-js-for-front-end- development
  • 57. ReactJS + GraphQL (Facebook) ā€¢ GraphQL: a server-side schema for graph-oriented data ā€¢ Can ā€œwrapā€ NoSQL and relational stores ā€¢ GraphQL server processes data requests from clients ā€¢ Data is returned to client apps ā€¢ http://githubengineering.com/the-github-graphql-api/ ā€¢ NB: GraphQL does not need Relay (but Relay needs GraphQL)
  • 58. GraphQL versus REST ā€¢ GraphQL is a ā€œfiner-grainedā€ alternative to REST ā€¢ REST is all-or-nothing: an ā€œentityā€ is returned ā€¢ GraphQL returns a subset of elements of an ā€œentityā€ ā€¢ Falcor from Netflix: GraphQL alternative (without a schema)
  • 59. GraphQL: What it isnā€™t ā€¢ GQL does not dictate a server language ā€¢ GQL does not dictate a storage/back-end ā€¢ GQL is a query language without a database
  • 60. GraphQL: What Does it Do? ā€¢ It exposes a single endpoint ā€¢ the endpoint parses and executes a query ā€¢ The query executes over a type system ā€¢ the type system is defined in the application server ā€¢ the type system is available via introspection (a GQL API)
  • 61. GraphQL Server Structure GraphQL servers have three components: ā€¢ 1) GraphQL ā€œcoreā€ (JavaScript and other languages) ā€¢ 2) Type Definitions (maps app code to internal system) ā€¢ 3) Application code (business logic)
  • 62. GraphQL Core: Five Components ā€¢ 1) Frontend lexer/parser: an AST [Relay uses parser] ā€¢ 2) Type System: GraphQLObjectType (a class) ā€¢ 3) Introspection: for querying types ā€¢ 4) Validation: is a query valid in the appā€™s schema? ā€¢ 5) Execution: manage query execution (via the AST)
  • 63. The GraphiQL IDE ā€¢ https://github.com/skevy/graphiql- app/blob/master/README.md ā€¢ https://github.com/skevy/graphiql-app/releases ā€¢ OSX: brew cask install graphiql
  • 64. GraphQL Queries (Interfaces) ā€¢ interface Employee { ā€¢ id: String! ā€¢ fname: String ā€¢ lname: String ā€¢ } ā€¢ ā€¢ type Query { ā€¢ emp: Employee ā€¢ }
  • 65. GraphQL Queries ā€¢ GraphQL Query: ā€¢ { ā€¢ emp { ā€¢ fname ā€¢ } ā€¢ } ā€¢ Response data: ā€¢ { ā€¢ "data": [{ ā€¢ "emp": { ā€¢ "fname": "John" ā€¢ } ā€¢ }] ā€¢ }
  • 66. GraphQL Queries ā€¢ query EmpNameQuery { ā€¢ emp { ā€¢ fname ā€¢ lname ā€¢ } ā€¢ } ā€¢ The result of the preceding query is here: ā€¢ { ā€¢ "data": [{ ā€¢ "emp": { ā€¢ "fname": "John", ā€¢ "lname": "Smith" ā€¢ } ā€¢ }] ā€¢ }
  • 67. GraphQL Websites ā€¢ Apollo: http://www.apollostack.com/ ā€œconsolidatesā€ data (removes duplicates in a tree) ā€¢ Reindex: https://www.reindex.io/blog/redux-and- relay ā€¢ Scaphold: scaphold.io ā€¢ Upcoming SF conference: http://graphqlsummit.com/
  • 68. GraphQL Websites ā€¢ Apollo: http://www.apollostack.com/ ā€œconsolidatesā€ data (removes duplicates in a tree) ā€¢ Reindex: https://www.reindex.io/blog/redux-and-relay ā€¢ Scaphold: https://scaphold.io/#/ ā€¢ GraphiQL: https://github.com/skevy/graphiql-app ā€¢ GraphQL conference: http://graphqlsummit.com/
  • 69. ReactJS + Relay (Facebook) ā€¢ Relay: a ā€œwrapperā€ around client-side components ā€¢ Data requests from a component ā€œgo throughā€ Relay ā€¢ Relay sends data requests to a GraphQL server ā€¢ Data is returned to client application ā€¢ Data is displayed according to application code/logic
  • 70. MERN: Mongo/Express/ReactJS/NodeJS ā€¢ http://mern.io/ ā€¢ MERN starter app: ā€¢ git clone https://github.com/Hashnode/mern-starter.git ā€¢ cd mern-starter ā€¢ npm install ā€¢ npm start ā€¢ MERN CLI: ā€¢ [sudo] npm install -g mern-cli ā€¢ mern init myApp ā€¢ cd myApp ā€¢ npm install ā€¢ npm start
  • 71. What is React Native? (Facebook) ā€¢ Facebook toolkit for cross-platform native mobile apps ā€¢ https://facebook.github.io/react-native/ ā€¢ You write custom JSX code for Android and iOS ā€¢ Update contents of index.android.js and index.ios.js ā€¢ Invoke react-native from command line ā€¢ Update cycle: Mobile app is updated via ā€œhot reloadingā€
  • 72. React Native Components ā€¢ https://github.com/react-native-community/react-native-elements ā€¢ Buttons ā€¢ Icons ā€¢ Social Icons / Buttons ā€¢ Side Menu ā€¢ Form Elements ā€¢ Search Bar ā€¢ ButtonGroup ā€¢ Checkboxes ā€¢ List Element ā€¢ Linked List Element ā€¢ Cross Platform Tab Bar ā€¢ HTML style headings (h1, h2, etc...) ā€¢ Card component ā€¢ Pricing Component
  • 73. React Native Installation ā€¢ iOS apps: make sure youā€™ve installed Xcode ā€¢ Android apps: install Java/Android/NDK: set JAVA_HOME, ANDROID_HOME, and NDK_HOME ā€¢ Now install react-native: [sudo] npm install ā€“g react-native ā€¢ Create an application: react-native new FirstApp Start an application: react-native run-android
  • 74. More Stuff About React Native ā€¢ Top-level element in render() must be a <View> element ā€¢ You can create custom native components (Android&iOS) ā€¢ Supports Flux/Redux/Relay/GraphQL ā€¢ React Native with Redux: https://github.com/ReactConvention/react-native-redux- starter-kit
  • 75. React Native IDEs/Toolkits IDES: Deco (open source) and XDE (from Exponent) Very good ā€œStarter kitsā€ (with lots of components): ignite: https://infinite.red/ignite nativebase: https://github.com/GeekyAnts/NativeBase react-native ble: https://github.com/Polidea/react-native- ble-plx react-native-bg-geo: https://github.com/transistorsoft/react-native-background- geolocation
  • 76. React Native IDEs/Toolkits reactpack: https://github.com/olahol/reactpack heatpack: https://github.com/olahol/reactpack create-react-app: https://github.com/facebookincubator/ fb testing tools: https://facebook.github.io/react/docs/test-utils.html enzyme: https://medium.com/airbnb-engineering/enzyme-javascript- testing-utilities-for-react-a417e5e5090f
  • 77. Some Useful Tools/IDEs ā€¢ Select an IDE: +WebStorm 10: free 30-day trial ($49/year) +Visual Studio Code (free) + Atom (free) with atom-TypeScript extension ā€¢ Command Line Tools: + npm, npmjs, gulp, grunt (older), broccoli, + webpack, browserify (older), jspm+systemjs https://github.com/addyosmani/es6-tools
  • 78. Useful Technologies to Learn ā€¢ Main features of ES6 (and methods in ECMA5) ā€¢ Sass/Bootstrap 4 (previously: less) ā€¢ https://react-bootstrap.github.io/ ā€¢ D3.js for Data Visualization ā€¢ React Native (=ReactJS for Native Mobile) ā€¢ https://egghead.io/react-redux-cheatsheets
  • 79. Recent/Upcoming Books and Training 1) HTML5 Canvas and CSS3 Graphics (2013) 2) jQuery, CSS3, and HTML5 for Mobile (2013) 3) HTML5 Pocket Primer (2013) 4) jQuery Pocket Primer (2013) 5) HTML5 Mobile Pocket Primer (2014) 6) D3 Pocket Primer (2015) 7) Python Pocket Primer (2015) 8) SVG Pocket Primer (2016) 9) CSS3 Pocket Primer (2016) 10) Angular 2 Pocket Primer (2017)