SlideShare une entreprise Scribd logo
1  sur  133
ReactJS
A JavaScript library for building user interfaces
By Hamed Farag
@hamed_farag
console.info(‘Hello, I am Hamed Farag!’);
// Hello, I am Hamed Farag!
 ReactJS:
 History, What, Why, How it works?
 Environment
 Component
 Functional & Class Components
 Component Lifecycle
 Handling Events
 Conditional Rendering
 Render List
 Form
 Communication
 External Data
 Routing
 Extensions
 File Structure
 Tips & Tricks.
Agenda
 JS History.
 ES6 Basics For ReactJS.
 Recommended Books.
 Web Components.
 Component Architecture.
 SPA.
 Browsers War.
 Netscape, 1995.
 Scheme in browser.
 Java.
 Scheme, Self and Java.
 10 days!
 Mocha, LiveScript and JavaScript.
 ECMAScript.
A brief history of JS
console.warn(‘ES6 Basics’);
// ECMAScript 2015 Basics
ES6 – ECMAScript 2015
 Modules, Import and Export
 Arrow functions
 Constructor functions
 Classes and Extends
 Bind, apply, call
 Var, let and const
 Template Literals – Back-tick
 Object Destructuring
 Default, Rest and Spread
ES6 – ECMAScript 2015 – Cont.
Modules, Import and Export
 Modular programming is used to break large applications into smaller blocks of manageable code.
 Module based coding eases the effort for maintenance and increases reusability.
ES6 – ECMAScript 2015 – Cont.
Modules, Import and Export
ES5
Modules at ES5
ES6 – ECMAScript 2015 – Cont.
Modules, Import and Export
ES5
Modules at ES5
ES6 – ECMAScript 2015 – Cont.
Modules, Import and Export
ES5
Modules with libraries, CommonJS and RequireJS(AMD)
OR
ES6 – ECMAScript 2015 – Cont.
Modules, Import and Export
ES5
Modules with libraries, CommonJS and RequireJS(AMD)
ES6 – ECMAScript 2015 – Cont.
Modules, Import and Export
ES6
Modules at ES6
OR
ES6 – ECMAScript 2015 – Cont.
Arrow functions
ES5
ES6 – ECMAScript 2015 – Cont.
Arrow functions
ES6
With ECMAScript 2015, JavaScript got arrow functions, which are mainly syntactic sugar for defining function
expressions and does not have its own this, arguments, super or new.target.
These function expressions are best suited for non-method functions, and they cannot be used as
constructors.
ES6 – ECMAScript 2015 – Cont.
Constructor functions
ES5
ES6 – ECMAScript 2015 – Cont.
Constructor functions
ES5All JavaScript objects inherit properties and methods from a prototype.
ES6 – ECMAScript 2015 – Cont.
Constructor functions
ES6
ES6 – ECMAScript 2015 – Cont.
Classes and Extends
ES6
 JavaScript classes, introduced in ECMAScript 2015
 Syntactical sugar over JavaScript's existing prototype-based inheritance.
 The class syntax does not introduce a new object-oriented inheritance model to JavaScript.
 Classes support static methods so you can called without instantiating their class and cannot be called through a
class instance.
 The extends keyword is used in class declarations or class expressions to create a class as a child of another class.
 The super keyword is used to call corresponding methods of super class.
ES6 – ECMAScript 2015 – Cont.
Classes and Extends
ES6
// stephen hawking
// Hi Neil Person
// Hi Neil astrophysicist
// Hello Neil Person
ES6 – ECMAScript 2015 – Cont.
Bind, Apply, Call and of course ‘THIS’
ES3/ES5
 Functions can be used in many different contexts, and they need to be able to work in each
situation. Even though this is typically assigned automatically, you can change its value to achieve
different goals.
There are three function methods that allow you to change the value of this.
 Remember that functions are objects, and objects can have methods, so functions can, too.
ES6 – ECMAScript 2015 – Cont.
Bind, Apply, Call and of course ‘THIS’
ES3/ES5
// Family Name(Call) : Tyson
// My Family Name(Call) : Hawking
// Family Name(Apply) : Tyson
// My Family Name(Apply) : Hawking
// Family Name(Bind) : Tyson
// My Family Name(Bind) : Hawking
ES6 – ECMAScript 2015 – Cont.
Var, let
ES5/ES6
var vs let
 Scope essentially means where these variables are
available for use. var declarations are globally scoped or
function/locally scoped.
 It is globally scoped when a var variable is declared
outside a function.
 var is function scoped when it is declared within a
function. This means that it is available and can be
accessed only within that function.
 let is block scoped { }
ES6 – ECMAScript 2015 – Cont.
const
const
 const declarations are block scoped
 const cannot be updated or re-declared
ES6
ES6 – ECMAScript 2015 – Cont.
ES6
Template literals are string literals allowing embedded expressions. You can use multi-line strings and
string interpolation features with them.
Template Literals – Back-tick
ES6 – ECMAScript 2015 – Cont.
ES6
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values
from arrays, or properties from objects, into distinct variables.
// ["The Universe in a Nutshell", "On the Shoulders of Giants"]
Object Destructuring
ES6 – ECMAScript 2015 – Cont.
ES6
Default function parameters allow formal parameters to be initialized with default values if no value or
undefined is passed.
Default
ES6 – ECMAScript 2015 – Cont.
ES6
The rest parameter syntax allows us to represent an indefinite number of arguments as an array.
Rest
ES6 – ECMAScript 2015 – Cont.
ES6
Spread syntax allows an iterable such as an array expression or string to be expanded in places where
zero or more arguments (for function calls) or elements (for array literals) are expected, or an object
expression to be expanded in places where zero or mor
Spread
ES6 – ECMAScript 2015 – Cont.
BabelJS
ES6
* Polyfill is code that implements a feature on web browsers that do not support the feature
*
Useful Books
 The Good Parts 1st Edition by Douglas Crockford
 The Principles of object-oriented javascript - by Nicholas C. Zakas
 You don’t know JS by Kyle Simpson
ES6 – ECMAScript 2015 – Cont.
Books
human.need(‘A Break’);
// don't be late
console.warn(‘Web Components’);
// Web Components
Web Components
Web Components is a suite of different technologies allowing you to create reusable custom elements — with their
functionality encapsulated away from the rest of your code — and utilize them in your web apps.
Four main technologies
 Custom elements.
 <Galaxy /> and register this custom tag so you can use it with your document.
 Shadow DOM.
 Attaching an encapsulated "shadow" DOM tree to an element.
 Resolve CSS Rules Problem for example.
 HTML templates.
 <template>
 HTTML imports.
 Example: <link rel="import" href="myfile.html">
Web Components
 The Shadow DOM is a browser technology designed primarily for scoping variables and CSS in
web components
 Browser support
 Not all browsers support this feature yet
 Polymer 2.0
 webcomponents.org
console.warn(‘Component Architecture’);
// Component-Based-Architecture
Component Architecture
 A method for encapsulating individual pieces of a larger user interface (aka components) into self-
sustaining, independent micro-systems.
 Components have their own structure, their own methods and their own APIs.
 Components are also reusable and can be “pasted” into interfaces at will.
 The independent nature of components allows for developers to create a UI with many different
moving parts.
 Components each have their own interfaces that can make calls to the server and update their
interfaces.
 Separation of Concern Component, MVC splits responsibilities horizontally, CBA splits them vertically.
Component Architecture
console.info(‘Jacuzzi and SPA’);
// You mean Single-Page Application !?
SPA – Single-Page Application
 Single-Page Applications (SPAs) are Web apps that load a single HTML page and dynamically
update that page as the user interacts with the app.
 SPAs use AJAX and HTML5 to create fluid and responsive Web apps, without constant page
reloads.
 This approach avoids interruption of the user experience between successive pages, making the application
behave more like a desktop application.
 Just HTML, JavaScript, and CSS.
 JavaScript frameworks (ReactJS, AngularJS, EmberJS, VueJS and so on)
 Ajax
 Websockets
 Browser History
SPA – Single-Page Application
Traditional Page Lifecycle
In a traditional Web app, every time
the app calls the server, the server
renders a new HTML page. This
triggers a page refresh in the
browser. If you’ve ever written a
Web Forms application, this page
lifecycle should look familiar.
Page
Reload
Initial Request
HTML
Form Post
HTML
Client Server
SPA – Single-Page Application
SPA Lifecycle
In an SPA, after the first page loads,
all interaction with the server
happens through AJAX calls. These
AJAX calls return data—not
markup—usually in JSON format.
The app uses the JSON data to
update the page dynamically,
without reloading the page.
Initial Request
HTML
Ajax
JSON
Client Server
{…}
console.info(‘Q & A’);
// Any Question ?
human.need(‘A Break’);
// don't be late
<UserCard user={cosmologist} />
/* Time to React */
const cosmologist = {
name: 'Neil Tyson',
imgURL: 'https://www.thefamouspeople.com/profiles/images/neil-degrasse-tyson-2.jpg'
}
React
History
 Created by Jordan Walke, a software engineer at Facebook.
 He was influenced by XHP, an HTML component framework for PHP.
 Allow XML syntax for the purpose of creating custom and reusable HTML elements.
 FaxJS
 Facebook 2011, Instagram 2012 and open-sourced 2013.
16.3.2 Called React Fiber.
 React Native 2015.
React
What?
 React is a JS library Building interactive user interfaces.
 So it is a View JS Library
 React can be used to create SPA and mobile applications.
 Still maintained by Facebook.
 Not a Framework it is just a Library.
 React is often used in conjunction with other libraries such as Redux or Flux.
React
 Component-Based, Reusable Components.
 Unidirectional data flow.
 Not templates to create.
 Work with any stack or framework.
 Native
 Declarative not Imperative
 Easy to learn
 Facebook
Why?
React
Why?
Declarative not Imperative, Imperative
React
Why?
Declarative not Imperative, Declarative
React
How it works?
Two-way Data Binding
Model View
Change to the VIEW
Update the MODEL
Change to the MODEL
Update the VIEW
React
How it works?
Dispatcher
Store/StateView
 Single Source of Truth.
 Provides predictable application state.
 Much easier to pinpoint where the error
lies, as data follows a strict pipeline
React is a Unidirectional-Data Binding
Bind Data
Update storeDispatch Action
React
How it works?
 DOM stands for Document Object Model and is an abstraction of a structured text. For web
developers, this text is an HTML code, and the DOM is simply called HTML DOM.
 So, while HTML is a text, the DOM is an in-memory (tree-structured) representation of this text.
1. Browser have to parses the HTML
2. It removes the child element of elementId
3. Updates the DOM with the “New Value”
4. Re-calculate the CSS for the parent and child
5. Update the layout i.e. each elements exact co-ordinates on the screen
6. Traverse the render tree and paint it on the browser display
DOM
React
How it works?
Virtual DOM
 Virtual DOM is in-memory representation of Real DOM. It is lightweight JavaScript object
which is copy of Real DOM.
 Updating virtual DOM in ReactJS is faster because ReactJS uses
1. Diff algorithm, compares both the Virtual DOM to find the minimum number of steps to
update the Real DOM.
2. Batched update operations.
3. Efficient update of sub tree only.
4. Uses observable instead of dirty checking to detect change.
ReactJS maintains two virtual DOM, one with the updated state Virtual DOM and other with the
previous state Virtual DOM.
React
How it works?
Virtual DOM
DOM
Different
Virtual DOM
Updated Virtual DOM
React
How it works?
JSX
React
How it works?
JSX
 This funny tag :D syntax is neither a string nor HTML.
 JSX may remind you of a template language, but it comes with the full power of JavaScript.
 JavaScript XML
 React doesn’t require using JSX, but most people find it helpful as a visual aid when working
with UI inside the JavaScript code. It also allows React to show more useful error and warning
messages.
 Embedding Expressions in JSX, Like Razor engine for example.
React
How it works?
JSX
React
How it works?
JSX
 Since JSX is closer to JavaScript than to HTML, React DOM uses camelCase property naming
convention instead of HTML attribute names.
 For example, class becomes className in JSX, and tabindex becomes tabIndex.
React
How it works?
JSX
React
How it works?
React-DOM
React-DOM
React
How it works?
React-DOM
 React and ReactDOM were only recently split into two different libraries.
 From 0.14 and up.
 ReactDOM is the glue between React and the DOM.
 Use it for one single thing: mounting with ReactDOM.render().
 Another useful feature of ReactDOM is ReactDOM.findDOMNode() which you can use to gain
direct access to a DOM element.
developer.need(‘A Demo’);
// hooooray :D
React
Recap
 What are the elements that I can render them?
 Strings.
 Components or HTML tags.
 Array of Strings, Components or HTML tags
 How to create React Element?
 Using JSX Syntax

 Note: Don’t forget to wrap the elements with a container
React
Environment
create-react-app
React
Environment
 Your preferred text editor. (Notepad :D, Notepad++, sublime, atom, VS Code ….)
 Install Node.JS 8.1
 GIT , https://git-scm.com/downloads
 npm install –g create-react-app
 create-react-app your-app-name *
 npm start
* Don’t forget to navigate into your-app-name folder before you
run npm start command
you.will(‘Prepare your Environment’);
// Loading …..
student.need(‘To Practice’);
// Lab time
Components
React
React
React Component
 Components let you split the UI into independent, reusable pieces, and think about each
piece in isolation.
 Like JavaScript functions.
 Accept any types and any numbers of properties ‘props’.
 React elements describing what should appear on the screen
 Two ways to define a component
 Functional Component
 Class Component
React
React Component
OR
Must start with Capital Case
React
React Component Properties - Props
 Component Properties – Props
 Can be anything (string, number, array, simple object, complex object).
 Props are Read-Only (immutable).
 Can have default values (static defaultProps).
 Can be validated at runtime (PropTypes).
 Top-Down, Parent can send whatever prop values it likes to a child, but the child cannot
modify its own props.
React
React Component State
 As Component has props, component has state.
 You can consider that "state" is a database in object shape.
 The heart of every React component (Statefull).
 Determines how that component renders & behaves.
 Private and fully controlled by the component.
 You can add initial values to the state.
 State cannot modified directly.
 Only with SetState(nextState, callback) function
 State Updates May Be Asynchronous
 State Updates are Merge
React
React Component State
 SetState(nextState, callback)
 React may batch multiple setState() calls into a single update for performance.
 It Rerender the whole component,
 The parent one and all children of this parent.
 Whenever setState() method is called, ReactJS creates the whole Virtual DOM from scratch. Creating a
whole tree is very fast so it does not affect the performance
programmer.need(‘A Demo’);
// finally !
React
Functional Component vs Class Component
Functional vs Class
 Receive parameter (Props) - Optional
 Stateless or dumb component.
 Just Plain old JavaScript functions.
 Shorter to write
 For UI Components
 Has local State
 Receive parameter (Props) - Optional
 Statefull or smart component
 Has Lifecycle hooks.
 Can Handles fetching data via ajax calls
React
Component Lifecycle
The Component Lifecycle
Each component has several “lifecycle methods” that you can override to run code at particular times
in the process.
Methods prefixed with will are called right before something happens, and methods prefixed
with did are called right after something happens.
React
Component Lifecycle – 4 Phases
Initialization Mounting
props
Unmounting
Setup props & state componentWillMount
render
componentDidMount
componentWillReceiveProps
shouldComponentUpdate
componentWillUpdate
componentWillUnmount
render
componentDidUpdate
componentWillUpdate
render
shouldComponentUpdate
componentDidUpdate
Updating
state
true
true
false
false
React
Component Lifecycle
 componentWillMount
 render
 componentDidMount
 componentWillReceiveProps
 shouldComponentUpdate
 componentWillUpdate
 componentDidupdate
 componentWillUnmount
 Immediately before initial rendering
 Render the elements.
 Immediately after initial rendering
 When component receives new props
 Before rendering, after receiving news props or state.
 Before rendering, after receiving news props or state.
 After component's updates are flushed to DOM.
 Immediately before removing component from DOM.
React
Component Lifecycle – Phase 1
Initialization
In this phase the React setting up the initial states
and default props, if any.
The component is setting up the initial state in
the constructor, which can be changed later by
using the setState method.
The defaultProps is defined as a property of
Component to define all the default value of
props, which can be overridden with new prop
values.
React
Component Lifecycle – Phase 2
Mounting
React Component now is ready to mount in the browser
DOM.
This phase gives hook methods for before and after
mounting of components.
• componentWillMount is executed just before the
React Component is about to mount on the DOM.
• render mounts the component onto the browser.
• componentDidMount this is the hook method which is
executed after the component did mount on the
DOM.
React
Component Lifecycle – Phase 3
Updating - Props
This phase starts when the react component has
taken birth on the browser and grows by receiving
new updates.
Can be updated by two ways, sending new props or
updating the state.
componentWillReceiveProps gets executed when
the props have changed and is not first render.
Usage: This is how the state can be kept synced with
the new props.
React
Component Lifecycle – Phase 3 - cont
Updating - Props
shouldComponentUpdate tells the React that when
the component receives new props or state is being
updated, should React re-render or it can skip
rendering?
Enhance performance of a slow component
React
Component Lifecycle – Phase 3 - cont
Updating - Props
componentWillUpdate is executed only after the
shouldComponentUpdate returns true. This method
is only used to do the preparation for the upcoming
render, similar to componentWillMount or
constructor.
React
Component Lifecycle – Phase 3 - cont
Updating - Props
componentDidUpdate is executed when the new
updated component has been updated in the DOM.
This method is used to re trigger the third party
libraries used to make sure these libraries also
update and reload themselves.
React
Component Lifecycle – Phase 4
Unmounting
componentWillUnmount This method is the last
method in the lifecycle. This is executed just before
the component gets removed from the DOM.
Usage: In this method, we do all the cleanups
related to the component.
React
Component Lifecycle
So
 Don’t use setState with
 constructor
 componentDidMount, and will cause a performance issue.
 componentWillUpdate, would trigger an update to a React component before
componentWillUpdate() returns
React
Component Lifecycle – Other Hooks
 forceUpdate()
 Calling forceUpdate() will cause render() to be called on the component, skipping
shouldComponentUpdate(). This will trigger the normal lifecycle methods for child components,
including the shouldComponentUpdate() method of each child. React will still only update the DOM if
the markup changes.
 Normally you should try to avoid all uses of forceUpdate() and only read from this.props and
this.state in render().
 componentDidCatch(error, info)
 catch JavaScript errors anywhere in their child component tree, log those errors, and display a
fallback UI instead of the component tree that crashed.
 Calling setState() in it lets you capture an unhandled JavaScript error in the below tree and display a
fallback UI.
React
Component Lifecycle – Diagrams
Component Creation Steps
render
constructor
componentWillMount
create and render all direct
child components
componentDidMount
A New Props Received
componentWillUpdate
componentWillReceiveProps
render
componentDidUpdate
shouldComponentUpdate
stop
true false
setState
componentWillUpdate
render
shouldComponentUpdate
stop
true false
Send new props to all
direct child components
componentDidUpdate
Send new props to all
direct child components
React
Handling Events
 Handling events with React elements is very similar to handling events on DOM elements.
There are some syntactic differences:
 React events are named using camelCase, rather than lowercase.
 With JSX you pass a function as the event handler, rather than a string.
 You cannot return false to prevent default behavior in React. You must call preventDefault explicitly.
React
Handling Events
 The BIND
 In JavaScript, class methods are not bound by default
 If you forget to bind this.onHandleClick and pass it to onClick, this will be undefined when the
function is actually called
engineer.need(‘A Demonstration’);
// why ?!
React
Conditional Rendering
 In React, you can create distinct components that encapsulate behavior you need. Then, you
can render only some of them, depending on the state of your application.
 It is all about if, else, switch statements and conditional (ternary) - ? : - operator.
 Logical && Operator
 Logical || Operator
 To Prevent a component from rendering just return null.
someone.need(‘A Demo’);
// again !!
React
How to render a List
 As we said before, What are the elements that I can render them?
 Strings.
 Components or HTML tags.
 Array of Strings, Components or HTML tags.
Must be An Array
creates a new array with the
results of calling a provided
function on every element in
the calling array.
React
How to render a List
 A “key” is a special string attribute you need to include when creating lists of elements.
Keys help React identify which items have
changed, are added, or are removed.
Keys should be given to the elements
inside the array to give the elements a
stable identity.
Keys Must Only Be Unique Among
Siblings
student.need(‘To Practice’);
// Lab time
React
Form
 HTML form elements work a little bit differently from other DOM elements in React, because
form elements naturally keep some internal state.
 Controlled components, input form element whose value is controlled by React
 In HTML, form elements such as <input>, <textarea>, and <select> typically maintain their
own state and update it based on user input. In React, mutable state is typically kept in the
state property of components, and only updated with setState().
 We can combine the two by making the React state be the “single source of truth”
React
Form - cont
Dispatcher
Store/StateView
Bind Data
Update storeDispatch Action
React
Form - cont
 Textarea Tag
 Select Tag
React
Form - cont
 Uncontrolled components, where form data is handled by the DOM itself.
 To write an uncontrolled component, instead of writing an event handler for every state update, you
can use a ref to get form values from the DOM.
 When to use refs?
 Managing focus, text selection, or media playback.
 Triggering imperative animations.
 Integrating with third-party DOM libraries Like Jquery.
geek.need(‘A Demo’);
// oh GOD !
React
Communication
Shared State (Lifting state up)
 Shared a state between two components.
 Removing the local state from the descendant component and move
it into its ancestor instead.
 When we update an input, an other component should reflect the
change (and vice versa).
 Remember: single source of truth
ancestor
descendants
Lifting State Up
React
Communication
Shared State (Lifting state up)
 What about this?
React
Communication
State Management Store
Out of the BOX!
React
React
Communication
State Management
FluxJS RefluxJS ReduxJS MobXJS
React
Redux
Redux
 Motivation
 Lost control over the when, why, and how of its state.
 Single Source of truth is to hard to maintain.
 Hard to reproduce bugs or add new features.
 Handle optimistic updates, server-side rendering, fetching data before performing route transitions will be
impossible.
React
Redux
State Management
Action Store
UI
React
Redux
State Management
Action Reducer Store
UI
React
Redux
Main Concepts
 Like React, Redux guarantee that data will be updated via Unidirectional data-binding
technique.
 So to update the state and it called Store at Redux, you need to
 Dispatch an action to update a portion at the store and it called Action Creator
 Action Creator return plain JS object called Action Object that describes what happened.
 Enforcing that every change is described as an action lets us have a clear understanding of what’s
going on in the app.
 Okay, to tie the state (store) with the action creators we need a function that handle the checks
and this function we called it (Reducer).
 Every time when you dispatches an action, store will broadcast this action to all the reducers
(including its sub-reducers). and if the action.type matches, then the reducer will handle this action
accordingly.
React
Redux
Three Principles
 Single source of truth.
 State is read-only.
 The only way to change the state is to emit an action, an object describing (action.type) what
happened.
 This ensures that neither the views nor the network callbacks will ever write directly to the state.
 Changes are made with pure functions
 Reducers are just pure functions that take the previous state and an action, and return the next state.
React
Redux Workflow
Action Creator
UI
Dispatch
Calculate and
return new store
Redux
Broadcast The
Action Object and
the current store
Reducer
Reducer
Reducer
Reducer
ReduxStore
Send the new
store to save it
Send Action
Object
Send the new
state for
updating
React
Redux
Action Creators & Actions
 Actions are payloads of information that send data from your application to your store.
 The only source of information for the store.
 You send them to the store using store.dispatch() as it dispatch Action Creator.
React
Redux
Reducer
 Specify how the application's state changes in response to actions sent to the store.Normal (Pure)
function
 Computes only the new state.
 Should be completely predictable: calling it with the same inputs many times should produce the
same outputs.
 Shouldn't perform any side effects like API calls or router transitions.
 You cannot update in state directly, you create a new object using Object.assign({}, state) then return it and the
redux will handle how to update the store.
 You can split the reducer to sub-reducers to so you can maintain it easily then you can combine them
React
Redux
Reducer
React
Redux
Store
 You'll only have a single store in a Redux application.
 If You want to split your data handling logic, you'll use reducer composition instead of many stores.
 New Reducer = New Store
 The store has the following responsibilities:
 Holds application state;
Allows access to state via getState();
Allows state to be updated via dispatch(action)
redux.need(‘A Demo’);
// sure !
React
Redux – Advanced Topics -Middleware
Middleware
 Redux middleware is nothing more than a function which is invoked after an action is dispatched
but before a reducer takes care of the action.
 Middleware are functions that allow us extend the functionality of our redux application.
React
Redux – Advanced Topics -Middleware
Broadcast The
Action Object and
the current store
Re
n Creator
Send Action
Object
Reduc
Middleware#1
Middleware#2
Middleware#3
Middleware#4
React
Redux – Advanced Topics -Middleware
Middleware
store => next => action => {
console.log(“Middleware need a Demo");
next(action);
}
we.need(‘A BONUS’);
// Ooooooooooooooooooooo
React
External Data
Ajax Calls
Axios
Library
ajax.call({ data: ‘A Demo’ });
// { status: 200, data: ‘Yesssss’ }
React
Routing
react-router
React
Routing
 Components are the heart of React's powerful, declarative programming model.
 React Router is a collection of navigational components that compose declaratively with your
application.
 Work with Web Application and React Native.
BrowserHistory.Push(‘/demo’);
// redirecting…
React
Extensions
student.need(‘To Practice’);
// Lab time
File Structure
React
ITWORX HUB
React
Case Study
Tips & Tricks
React
HamedFarag.Say(‘Thanks 4 ur attention’);
{
twitter: @hamed_farag
www: hamedfarag.com
slack: frontend-geeks.slack.com
}

Contenu connexe

Tendances

Tendances (20)

React state
React  stateReact  state
React state
 
React JS
React JSReact JS
React JS
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
What is component in reactjs
What is component in reactjsWhat is component in reactjs
What is component in reactjs
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
reactJS
reactJSreactJS
reactJS
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)State management in react applications (Statecharts)
State management in react applications (Statecharts)
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
React Router: React Meetup XXL
React Router: React Meetup XXLReact Router: React Meetup XXL
React Router: React Meetup XXL
 
React hooks
React hooksReact hooks
React hooks
 
React for Beginners
React for BeginnersReact for Beginners
React for Beginners
 
React hooks
React hooksReact hooks
React hooks
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 

Similaire à React & Redux JS

Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
Before you jump into Angular
Before you jump into AngularBefore you jump into Angular
Before you jump into AngularM A Hossain Tonu
 
Corso su ReactJS
Corso su ReactJSCorso su ReactJS
Corso su ReactJSLinkMe Srl
 
ASP.NET MVC - In the Wild
ASP.NET MVC - In the WildASP.NET MVC - In the Wild
ASP.NET MVC - In the WildBrian Boatright
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSAlberto Paro
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsScala Italy
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overviewskill-guru
 
My 70-480 HTML5 certification learning
My 70-480 HTML5 certification learningMy 70-480 HTML5 certification learning
My 70-480 HTML5 certification learningSyed Irtaza Ali
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET PresentationRasel Khan
 
From SOA to SCA and FraSCAti
From SOA to SCA and FraSCAtiFrom SOA to SCA and FraSCAti
From SOA to SCA and FraSCAtiphilippe_merle
 
Java script Basic
Java script BasicJava script Basic
Java script BasicJaya Kumari
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day trainingTroy Miles
 
Tuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperTuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperVinay Kumar
 
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components Ben Edwards
 
Flex 4.5 jeyasekar
Flex 4.5  jeyasekarFlex 4.5  jeyasekar
Flex 4.5 jeyasekarjeya soft
 

Similaire à React & Redux JS (20)

Lezione 03 Introduzione a react
Lezione 03   Introduzione a reactLezione 03   Introduzione a react
Lezione 03 Introduzione a react
 
User Interface
User InterfaceUser Interface
User Interface
 
ReactJS.pptx
ReactJS.pptxReactJS.pptx
ReactJS.pptx
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
Before you jump into Angular
Before you jump into AngularBefore you jump into Angular
Before you jump into Angular
 
Corso su ReactJS
Corso su ReactJSCorso su ReactJS
Corso su ReactJS
 
ASP.NET MVC - In the Wild
ASP.NET MVC - In the WildASP.NET MVC - In the Wild
ASP.NET MVC - In the Wild
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
 
My 70-480 HTML5 certification learning
My 70-480 HTML5 certification learningMy 70-480 HTML5 certification learning
My 70-480 HTML5 certification learning
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
Java server pages
Java server pagesJava server pages
Java server pages
 
From SOA to SCA and FraSCAti
From SOA to SCA and FraSCAtiFrom SOA to SCA and FraSCAti
From SOA to SCA and FraSCAti
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
 
Tuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperTuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paper
 
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
 
Flex 4.5 jeyasekar
Flex 4.5  jeyasekarFlex 4.5  jeyasekar
Flex 4.5 jeyasekar
 

Dernier

Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
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
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
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
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 

Dernier (20)

Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
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 🔝✔️✔️
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
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-...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
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
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

React & Redux JS

  • 1. ReactJS A JavaScript library for building user interfaces By Hamed Farag @hamed_farag
  • 2. console.info(‘Hello, I am Hamed Farag!’); // Hello, I am Hamed Farag!
  • 3.  ReactJS:  History, What, Why, How it works?  Environment  Component  Functional & Class Components  Component Lifecycle  Handling Events  Conditional Rendering  Render List  Form  Communication  External Data  Routing  Extensions  File Structure  Tips & Tricks. Agenda  JS History.  ES6 Basics For ReactJS.  Recommended Books.  Web Components.  Component Architecture.  SPA.
  • 4.  Browsers War.  Netscape, 1995.  Scheme in browser.  Java.  Scheme, Self and Java.  10 days!  Mocha, LiveScript and JavaScript.  ECMAScript. A brief history of JS
  • 6. ES6 – ECMAScript 2015  Modules, Import and Export  Arrow functions  Constructor functions  Classes and Extends  Bind, apply, call  Var, let and const  Template Literals – Back-tick  Object Destructuring  Default, Rest and Spread
  • 7. ES6 – ECMAScript 2015 – Cont. Modules, Import and Export  Modular programming is used to break large applications into smaller blocks of manageable code.  Module based coding eases the effort for maintenance and increases reusability.
  • 8. ES6 – ECMAScript 2015 – Cont. Modules, Import and Export ES5 Modules at ES5
  • 9. ES6 – ECMAScript 2015 – Cont. Modules, Import and Export ES5 Modules at ES5
  • 10. ES6 – ECMAScript 2015 – Cont. Modules, Import and Export ES5 Modules with libraries, CommonJS and RequireJS(AMD) OR
  • 11. ES6 – ECMAScript 2015 – Cont. Modules, Import and Export ES5 Modules with libraries, CommonJS and RequireJS(AMD)
  • 12. ES6 – ECMAScript 2015 – Cont. Modules, Import and Export ES6 Modules at ES6 OR
  • 13. ES6 – ECMAScript 2015 – Cont. Arrow functions ES5
  • 14. ES6 – ECMAScript 2015 – Cont. Arrow functions ES6 With ECMAScript 2015, JavaScript got arrow functions, which are mainly syntactic sugar for defining function expressions and does not have its own this, arguments, super or new.target. These function expressions are best suited for non-method functions, and they cannot be used as constructors.
  • 15. ES6 – ECMAScript 2015 – Cont. Constructor functions ES5
  • 16. ES6 – ECMAScript 2015 – Cont. Constructor functions ES5All JavaScript objects inherit properties and methods from a prototype.
  • 17. ES6 – ECMAScript 2015 – Cont. Constructor functions ES6
  • 18. ES6 – ECMAScript 2015 – Cont. Classes and Extends ES6  JavaScript classes, introduced in ECMAScript 2015  Syntactical sugar over JavaScript's existing prototype-based inheritance.  The class syntax does not introduce a new object-oriented inheritance model to JavaScript.  Classes support static methods so you can called without instantiating their class and cannot be called through a class instance.  The extends keyword is used in class declarations or class expressions to create a class as a child of another class.  The super keyword is used to call corresponding methods of super class.
  • 19. ES6 – ECMAScript 2015 – Cont. Classes and Extends ES6 // stephen hawking // Hi Neil Person // Hi Neil astrophysicist // Hello Neil Person
  • 20. ES6 – ECMAScript 2015 – Cont. Bind, Apply, Call and of course ‘THIS’ ES3/ES5  Functions can be used in many different contexts, and they need to be able to work in each situation. Even though this is typically assigned automatically, you can change its value to achieve different goals. There are three function methods that allow you to change the value of this.  Remember that functions are objects, and objects can have methods, so functions can, too.
  • 21. ES6 – ECMAScript 2015 – Cont. Bind, Apply, Call and of course ‘THIS’ ES3/ES5 // Family Name(Call) : Tyson // My Family Name(Call) : Hawking // Family Name(Apply) : Tyson // My Family Name(Apply) : Hawking // Family Name(Bind) : Tyson // My Family Name(Bind) : Hawking
  • 22. ES6 – ECMAScript 2015 – Cont. Var, let ES5/ES6 var vs let  Scope essentially means where these variables are available for use. var declarations are globally scoped or function/locally scoped.  It is globally scoped when a var variable is declared outside a function.  var is function scoped when it is declared within a function. This means that it is available and can be accessed only within that function.  let is block scoped { }
  • 23. ES6 – ECMAScript 2015 – Cont. const const  const declarations are block scoped  const cannot be updated or re-declared ES6
  • 24. ES6 – ECMAScript 2015 – Cont. ES6 Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them. Template Literals – Back-tick
  • 25. ES6 – ECMAScript 2015 – Cont. ES6 The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. // ["The Universe in a Nutshell", "On the Shoulders of Giants"] Object Destructuring
  • 26. ES6 – ECMAScript 2015 – Cont. ES6 Default function parameters allow formal parameters to be initialized with default values if no value or undefined is passed. Default
  • 27. ES6 – ECMAScript 2015 – Cont. ES6 The rest parameter syntax allows us to represent an indefinite number of arguments as an array. Rest
  • 28. ES6 – ECMAScript 2015 – Cont. ES6 Spread syntax allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or mor Spread
  • 29. ES6 – ECMAScript 2015 – Cont. BabelJS ES6 * Polyfill is code that implements a feature on web browsers that do not support the feature *
  • 30. Useful Books  The Good Parts 1st Edition by Douglas Crockford  The Principles of object-oriented javascript - by Nicholas C. Zakas  You don’t know JS by Kyle Simpson ES6 – ECMAScript 2015 – Cont. Books
  • 33. Web Components Web Components is a suite of different technologies allowing you to create reusable custom elements — with their functionality encapsulated away from the rest of your code — and utilize them in your web apps. Four main technologies  Custom elements.  <Galaxy /> and register this custom tag so you can use it with your document.  Shadow DOM.  Attaching an encapsulated "shadow" DOM tree to an element.  Resolve CSS Rules Problem for example.  HTML templates.  <template>  HTTML imports.  Example: <link rel="import" href="myfile.html">
  • 34. Web Components  The Shadow DOM is a browser technology designed primarily for scoping variables and CSS in web components  Browser support  Not all browsers support this feature yet  Polymer 2.0  webcomponents.org
  • 36. Component Architecture  A method for encapsulating individual pieces of a larger user interface (aka components) into self- sustaining, independent micro-systems.  Components have their own structure, their own methods and their own APIs.  Components are also reusable and can be “pasted” into interfaces at will.  The independent nature of components allows for developers to create a UI with many different moving parts.  Components each have their own interfaces that can make calls to the server and update their interfaces.  Separation of Concern Component, MVC splits responsibilities horizontally, CBA splits them vertically.
  • 38. console.info(‘Jacuzzi and SPA’); // You mean Single-Page Application !?
  • 39. SPA – Single-Page Application  Single-Page Applications (SPAs) are Web apps that load a single HTML page and dynamically update that page as the user interacts with the app.  SPAs use AJAX and HTML5 to create fluid and responsive Web apps, without constant page reloads.  This approach avoids interruption of the user experience between successive pages, making the application behave more like a desktop application.  Just HTML, JavaScript, and CSS.  JavaScript frameworks (ReactJS, AngularJS, EmberJS, VueJS and so on)  Ajax  Websockets  Browser History
  • 40. SPA – Single-Page Application Traditional Page Lifecycle In a traditional Web app, every time the app calls the server, the server renders a new HTML page. This triggers a page refresh in the browser. If you’ve ever written a Web Forms application, this page lifecycle should look familiar. Page Reload Initial Request HTML Form Post HTML Client Server
  • 41. SPA – Single-Page Application SPA Lifecycle In an SPA, after the first page loads, all interaction with the server happens through AJAX calls. These AJAX calls return data—not markup—usually in JSON format. The app uses the JSON data to update the page dynamically, without reloading the page. Initial Request HTML Ajax JSON Client Server {…}
  • 44. <UserCard user={cosmologist} /> /* Time to React */ const cosmologist = { name: 'Neil Tyson', imgURL: 'https://www.thefamouspeople.com/profiles/images/neil-degrasse-tyson-2.jpg' }
  • 45. React History  Created by Jordan Walke, a software engineer at Facebook.  He was influenced by XHP, an HTML component framework for PHP.  Allow XML syntax for the purpose of creating custom and reusable HTML elements.  FaxJS  Facebook 2011, Instagram 2012 and open-sourced 2013. 16.3.2 Called React Fiber.  React Native 2015.
  • 46. React What?  React is a JS library Building interactive user interfaces.  So it is a View JS Library  React can be used to create SPA and mobile applications.  Still maintained by Facebook.  Not a Framework it is just a Library.  React is often used in conjunction with other libraries such as Redux or Flux.
  • 47. React  Component-Based, Reusable Components.  Unidirectional data flow.  Not templates to create.  Work with any stack or framework.  Native  Declarative not Imperative  Easy to learn  Facebook Why?
  • 50. React How it works? Two-way Data Binding Model View Change to the VIEW Update the MODEL Change to the MODEL Update the VIEW
  • 51. React How it works? Dispatcher Store/StateView  Single Source of Truth.  Provides predictable application state.  Much easier to pinpoint where the error lies, as data follows a strict pipeline React is a Unidirectional-Data Binding Bind Data Update storeDispatch Action
  • 52. React How it works?  DOM stands for Document Object Model and is an abstraction of a structured text. For web developers, this text is an HTML code, and the DOM is simply called HTML DOM.  So, while HTML is a text, the DOM is an in-memory (tree-structured) representation of this text. 1. Browser have to parses the HTML 2. It removes the child element of elementId 3. Updates the DOM with the “New Value” 4. Re-calculate the CSS for the parent and child 5. Update the layout i.e. each elements exact co-ordinates on the screen 6. Traverse the render tree and paint it on the browser display DOM
  • 53. React How it works? Virtual DOM  Virtual DOM is in-memory representation of Real DOM. It is lightweight JavaScript object which is copy of Real DOM.  Updating virtual DOM in ReactJS is faster because ReactJS uses 1. Diff algorithm, compares both the Virtual DOM to find the minimum number of steps to update the Real DOM. 2. Batched update operations. 3. Efficient update of sub tree only. 4. Uses observable instead of dirty checking to detect change. ReactJS maintains two virtual DOM, one with the updated state Virtual DOM and other with the previous state Virtual DOM.
  • 54. React How it works? Virtual DOM DOM Different Virtual DOM Updated Virtual DOM
  • 56. React How it works? JSX  This funny tag :D syntax is neither a string nor HTML.  JSX may remind you of a template language, but it comes with the full power of JavaScript.  JavaScript XML  React doesn’t require using JSX, but most people find it helpful as a visual aid when working with UI inside the JavaScript code. It also allows React to show more useful error and warning messages.  Embedding Expressions in JSX, Like Razor engine for example.
  • 58. React How it works? JSX  Since JSX is closer to JavaScript than to HTML, React DOM uses camelCase property naming convention instead of HTML attribute names.  For example, class becomes className in JSX, and tabindex becomes tabIndex.
  • 61. React How it works? React-DOM  React and ReactDOM were only recently split into two different libraries.  From 0.14 and up.  ReactDOM is the glue between React and the DOM.  Use it for one single thing: mounting with ReactDOM.render().  Another useful feature of ReactDOM is ReactDOM.findDOMNode() which you can use to gain direct access to a DOM element.
  • 63. React Recap  What are the elements that I can render them?  Strings.  Components or HTML tags.  Array of Strings, Components or HTML tags  How to create React Element?  Using JSX Syntax   Note: Don’t forget to wrap the elements with a container
  • 65. React Environment  Your preferred text editor. (Notepad :D, Notepad++, sublime, atom, VS Code ….)  Install Node.JS 8.1  GIT , https://git-scm.com/downloads  npm install –g create-react-app  create-react-app your-app-name *  npm start * Don’t forget to navigate into your-app-name folder before you run npm start command
  • 69. React React Component  Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.  Like JavaScript functions.  Accept any types and any numbers of properties ‘props’.  React elements describing what should appear on the screen  Two ways to define a component  Functional Component  Class Component
  • 71. React React Component Properties - Props  Component Properties – Props  Can be anything (string, number, array, simple object, complex object).  Props are Read-Only (immutable).  Can have default values (static defaultProps).  Can be validated at runtime (PropTypes).  Top-Down, Parent can send whatever prop values it likes to a child, but the child cannot modify its own props.
  • 72. React React Component State  As Component has props, component has state.  You can consider that "state" is a database in object shape.  The heart of every React component (Statefull).  Determines how that component renders & behaves.  Private and fully controlled by the component.  You can add initial values to the state.  State cannot modified directly.  Only with SetState(nextState, callback) function  State Updates May Be Asynchronous  State Updates are Merge
  • 73. React React Component State  SetState(nextState, callback)  React may batch multiple setState() calls into a single update for performance.  It Rerender the whole component,  The parent one and all children of this parent.  Whenever setState() method is called, ReactJS creates the whole Virtual DOM from scratch. Creating a whole tree is very fast so it does not affect the performance
  • 75. React Functional Component vs Class Component Functional vs Class  Receive parameter (Props) - Optional  Stateless or dumb component.  Just Plain old JavaScript functions.  Shorter to write  For UI Components  Has local State  Receive parameter (Props) - Optional  Statefull or smart component  Has Lifecycle hooks.  Can Handles fetching data via ajax calls
  • 76. React Component Lifecycle The Component Lifecycle Each component has several “lifecycle methods” that you can override to run code at particular times in the process. Methods prefixed with will are called right before something happens, and methods prefixed with did are called right after something happens.
  • 77. React Component Lifecycle – 4 Phases Initialization Mounting props Unmounting Setup props & state componentWillMount render componentDidMount componentWillReceiveProps shouldComponentUpdate componentWillUpdate componentWillUnmount render componentDidUpdate componentWillUpdate render shouldComponentUpdate componentDidUpdate Updating state true true false false
  • 78. React Component Lifecycle  componentWillMount  render  componentDidMount  componentWillReceiveProps  shouldComponentUpdate  componentWillUpdate  componentDidupdate  componentWillUnmount  Immediately before initial rendering  Render the elements.  Immediately after initial rendering  When component receives new props  Before rendering, after receiving news props or state.  Before rendering, after receiving news props or state.  After component's updates are flushed to DOM.  Immediately before removing component from DOM.
  • 79. React Component Lifecycle – Phase 1 Initialization In this phase the React setting up the initial states and default props, if any. The component is setting up the initial state in the constructor, which can be changed later by using the setState method. The defaultProps is defined as a property of Component to define all the default value of props, which can be overridden with new prop values.
  • 80. React Component Lifecycle – Phase 2 Mounting React Component now is ready to mount in the browser DOM. This phase gives hook methods for before and after mounting of components. • componentWillMount is executed just before the React Component is about to mount on the DOM. • render mounts the component onto the browser. • componentDidMount this is the hook method which is executed after the component did mount on the DOM.
  • 81. React Component Lifecycle – Phase 3 Updating - Props This phase starts when the react component has taken birth on the browser and grows by receiving new updates. Can be updated by two ways, sending new props or updating the state. componentWillReceiveProps gets executed when the props have changed and is not first render. Usage: This is how the state can be kept synced with the new props.
  • 82. React Component Lifecycle – Phase 3 - cont Updating - Props shouldComponentUpdate tells the React that when the component receives new props or state is being updated, should React re-render or it can skip rendering? Enhance performance of a slow component
  • 83. React Component Lifecycle – Phase 3 - cont Updating - Props componentWillUpdate is executed only after the shouldComponentUpdate returns true. This method is only used to do the preparation for the upcoming render, similar to componentWillMount or constructor.
  • 84. React Component Lifecycle – Phase 3 - cont Updating - Props componentDidUpdate is executed when the new updated component has been updated in the DOM. This method is used to re trigger the third party libraries used to make sure these libraries also update and reload themselves.
  • 85. React Component Lifecycle – Phase 4 Unmounting componentWillUnmount This method is the last method in the lifecycle. This is executed just before the component gets removed from the DOM. Usage: In this method, we do all the cleanups related to the component.
  • 86. React Component Lifecycle So  Don’t use setState with  constructor  componentDidMount, and will cause a performance issue.  componentWillUpdate, would trigger an update to a React component before componentWillUpdate() returns
  • 87. React Component Lifecycle – Other Hooks  forceUpdate()  Calling forceUpdate() will cause render() to be called on the component, skipping shouldComponentUpdate(). This will trigger the normal lifecycle methods for child components, including the shouldComponentUpdate() method of each child. React will still only update the DOM if the markup changes.  Normally you should try to avoid all uses of forceUpdate() and only read from this.props and this.state in render().  componentDidCatch(error, info)  catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed.  Calling setState() in it lets you capture an unhandled JavaScript error in the below tree and display a fallback UI.
  • 88. React Component Lifecycle – Diagrams Component Creation Steps render constructor componentWillMount create and render all direct child components componentDidMount A New Props Received componentWillUpdate componentWillReceiveProps render componentDidUpdate shouldComponentUpdate stop true false setState componentWillUpdate render shouldComponentUpdate stop true false Send new props to all direct child components componentDidUpdate Send new props to all direct child components
  • 89. React Handling Events  Handling events with React elements is very similar to handling events on DOM elements. There are some syntactic differences:  React events are named using camelCase, rather than lowercase.  With JSX you pass a function as the event handler, rather than a string.  You cannot return false to prevent default behavior in React. You must call preventDefault explicitly.
  • 90. React Handling Events  The BIND  In JavaScript, class methods are not bound by default  If you forget to bind this.onHandleClick and pass it to onClick, this will be undefined when the function is actually called
  • 92. React Conditional Rendering  In React, you can create distinct components that encapsulate behavior you need. Then, you can render only some of them, depending on the state of your application.  It is all about if, else, switch statements and conditional (ternary) - ? : - operator.  Logical && Operator  Logical || Operator  To Prevent a component from rendering just return null.
  • 94. React How to render a List  As we said before, What are the elements that I can render them?  Strings.  Components or HTML tags.  Array of Strings, Components or HTML tags. Must be An Array creates a new array with the results of calling a provided function on every element in the calling array.
  • 95. React How to render a List  A “key” is a special string attribute you need to include when creating lists of elements. Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array to give the elements a stable identity. Keys Must Only Be Unique Among Siblings
  • 97. React Form  HTML form elements work a little bit differently from other DOM elements in React, because form elements naturally keep some internal state.  Controlled components, input form element whose value is controlled by React  In HTML, form elements such as <input>, <textarea>, and <select> typically maintain their own state and update it based on user input. In React, mutable state is typically kept in the state property of components, and only updated with setState().  We can combine the two by making the React state be the “single source of truth”
  • 98. React Form - cont Dispatcher Store/StateView Bind Data Update storeDispatch Action
  • 99. React Form - cont  Textarea Tag  Select Tag
  • 100. React Form - cont  Uncontrolled components, where form data is handled by the DOM itself.  To write an uncontrolled component, instead of writing an event handler for every state update, you can use a ref to get form values from the DOM.  When to use refs?  Managing focus, text selection, or media playback.  Triggering imperative animations.  Integrating with third-party DOM libraries Like Jquery.
  • 102. React Communication Shared State (Lifting state up)  Shared a state between two components.  Removing the local state from the descendant component and move it into its ancestor instead.  When we update an input, an other component should reflect the change (and vice versa).  Remember: single source of truth ancestor descendants Lifting State Up
  • 103. React Communication Shared State (Lifting state up)  What about this?
  • 105. Out of the BOX! React
  • 107. React Redux Redux  Motivation  Lost control over the when, why, and how of its state.  Single Source of truth is to hard to maintain.  Hard to reproduce bugs or add new features.  Handle optimistic updates, server-side rendering, fetching data before performing route transitions will be impossible.
  • 110. React Redux Main Concepts  Like React, Redux guarantee that data will be updated via Unidirectional data-binding technique.  So to update the state and it called Store at Redux, you need to  Dispatch an action to update a portion at the store and it called Action Creator  Action Creator return plain JS object called Action Object that describes what happened.  Enforcing that every change is described as an action lets us have a clear understanding of what’s going on in the app.  Okay, to tie the state (store) with the action creators we need a function that handle the checks and this function we called it (Reducer).  Every time when you dispatches an action, store will broadcast this action to all the reducers (including its sub-reducers). and if the action.type matches, then the reducer will handle this action accordingly.
  • 111. React Redux Three Principles  Single source of truth.  State is read-only.  The only way to change the state is to emit an action, an object describing (action.type) what happened.  This ensures that neither the views nor the network callbacks will ever write directly to the state.  Changes are made with pure functions  Reducers are just pure functions that take the previous state and an action, and return the next state.
  • 112. React Redux Workflow Action Creator UI Dispatch Calculate and return new store Redux Broadcast The Action Object and the current store Reducer Reducer Reducer Reducer ReduxStore Send the new store to save it Send Action Object Send the new state for updating
  • 113. React Redux Action Creators & Actions  Actions are payloads of information that send data from your application to your store.  The only source of information for the store.  You send them to the store using store.dispatch() as it dispatch Action Creator.
  • 114. React Redux Reducer  Specify how the application's state changes in response to actions sent to the store.Normal (Pure) function  Computes only the new state.  Should be completely predictable: calling it with the same inputs many times should produce the same outputs.  Shouldn't perform any side effects like API calls or router transitions.  You cannot update in state directly, you create a new object using Object.assign({}, state) then return it and the redux will handle how to update the store.  You can split the reducer to sub-reducers to so you can maintain it easily then you can combine them
  • 116. React Redux Store  You'll only have a single store in a Redux application.  If You want to split your data handling logic, you'll use reducer composition instead of many stores.  New Reducer = New Store  The store has the following responsibilities:  Holds application state; Allows access to state via getState(); Allows state to be updated via dispatch(action)
  • 118. React Redux – Advanced Topics -Middleware Middleware  Redux middleware is nothing more than a function which is invoked after an action is dispatched but before a reducer takes care of the action.  Middleware are functions that allow us extend the functionality of our redux application.
  • 119. React Redux – Advanced Topics -Middleware Broadcast The Action Object and the current store Re n Creator Send Action Object Reduc Middleware#1 Middleware#2 Middleware#3 Middleware#4
  • 120. React Redux – Advanced Topics -Middleware Middleware
  • 121. store => next => action => { console.log(“Middleware need a Demo"); next(action); }
  • 124. ajax.call({ data: ‘A Demo’ }); // { status: 200, data: ‘Yesssss’ }
  • 126. React Routing  Components are the heart of React's powerful, declarative programming model.  React Router is a collection of navigational components that compose declaratively with your application.  Work with Web Application and React Native.
  • 133. HamedFarag.Say(‘Thanks 4 ur attention’); { twitter: @hamed_farag www: hamedfarag.com slack: frontend-geeks.slack.com }

Notes de l'éditeur

  1. https://github.com/grab/front-end-guide
  2. https://en.wikipedia.org/wiki/Browser_wars https://en.wikipedia.org/wiki/Brendan_Eich https://en.wikipedia.org/wiki/JavaScript https://en.wikipedia.org/wiki/ECMAScript http://2ality.com/2011/03/javascript-how-it-all-began.html https://www.coursera.org/learn/javascript-jquery-json/lecture/h5d03/bonus-brendan-eich-inventing-javascript https://www.w3schools.com/js/js_versions.asp http://blog.hamedfarag.com/post/2016/09/13/%D8%AA%D8%A7%D8%B1%D9%8A%D8%AE-%D8%A7%D9%84%D8%AC%D8%A7%D9%81%D8%A7-%D8%B3%D9%83%D8%B1%D9%8A%D8%A8%D8%AA (1)Using the basic syntax of C language,  (2)Using Java language data types and memory management,  (3)Using Scheme language, ascension will function to the "first citizen" (first class) status,  (4)Using Self language, the use of prototype based inheritance mechanism (prototype). 
  3. Apply, filter, reduce in js
  4. http://es6-features.org/#Constants http://blog.revathskumar.com/2016/02/reactjs-writing-in-es6.html
  5. https://auth0.com/blog/javascript-module-systems-showdown/
  6. IIFE https://en.wikipedia.org/wiki/Immediately-invoked_function_expression Encapsulation First Class Object https://www.c-sharpcorner.com/article/first-class-function-in-javascript/ Pass as parameter. Return the function from another function. Assign a function to a variable. Assign to a property at object. Function can have the properties. https://stackoverflow.com/questions/705173/what-is-meant-by-first-class-object?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa var calculator = (function () { var _add = function (a, b) { return a + b; } var _subtract = function (a, b) { return a - b; } var _multiply= function (a, b) { return a * b; } var _divide = function (a, b) { return a / b; } return { add: _add, subtract: _subtract, multiply: _multiply, divide: _divide } }()) var main = (function(calculator){ console.info(calculator.add(1, 3)); }(calculator));
  7. https://auth0.com/blog/javascript-module-systems-showdown/ PROS Simple enough to be implemented anywhere (no libraries, no language support required). Multiple modules can be defined in a single file. CONS No way to programmatically import modules (except by using eval). Dependencies need to be handled manually. Asynchronous loading of modules is not possible. Circular dependencies can be troublesome. Hard to analyze for static code analyzers. var calculator = (function () { var add = function (a, b) { return a + b; } var subtract = function (a, b) { return a - b; } var multiply= function (a, b) { return a * b; } var divide = function (a, b) { return a / b; } var _isNumber = function(a){ return Number.isInteger(a); } return { add: add, subtract: subtract, multiply: multiply, divide: divide } }()) <body> <script src="./calculator.js"></script> <script src="./main.js"></script> </body>
  8. https://auth0.com/blog/javascript-module-systems-showdown/ https://www.sitepoint.com/understanding-requirejs-for-effective-javascript-module-loading/ PROS Simple: a developer can grasp the concept without looking at the docs. Dependency management is integrated: modules require other modules and get loaded in the needed order. require can be called anywhere: modules can be loaded programmatically. Circular dependencies are supported. CONS Synchronous API makes it not suitable for certain uses (client-side). One file per module. Browsers require a loader library or transpiling. No constructor function for modules (Node supports this though). Hard to analyze for static code analyzers. module.exports = { add : function (a, b) { return a + b; }, subtract : function (a, b) { return a - b; }, multiply : function (a, b) { return a * b; }, divide : function (a, b) { return a / b; } } exports.add = function (a, b) { return a + b; } exports.subtract = function (a, b) { return a - b; } exports.multiply= function (a, b) { return a * b; } exports.divide = function (a, b) { return a / b; } var _isNumber = function(a){ return Number.isInteger(a); } var calculator = require('./calculator.js'); console.info(calculator.add(1, 3));
  9. https://auth0.com/blog/javascript-module-systems-showdown/ https://www.sitepoint.com/understanding-requirejs-for-effective-javascript-module-loading/ PROS Asynchronous loading (better startup times). Circular dependencies are supported. Compatibility for require and exports. Dependency management fully integrated. Modules can be split in multiple files if necessary. Constructor functions are supported. Plugin support (custom loading steps). CONS Slightly more complex syntactically. Loader libraries are required unless transpiled. Hard to analyze for static code analyzers. define(function () { var add = function (a, b) { return a + b; } var subtract = function (a, b) { return a - b; } var multiply= function (a, b) { return a * b; } var divide = function (a, b) { return a / b; } return { add: add, subtract: subtract, multiply: multiply, divide: divide } }); requirejs(['./calculator'], function (calculator) { console.info(calculator.add(1, 3)); });
  10. http://2ality.com/2014/09/es6-modules-final.html https://auth0.com/blog/javascript-module-systems-showdo export default function add(a, b) { return a + b; } export function subtract(a, b) { return a - b; } export function multiply(a, b) { return a * b; } export function divide(a, b) { return a / b; } import add, {subtract, multiply, divide} from './calculator'; import { default as add, subtract, multiply, divide} from './calculator'; wn/
  11. Hoisting -> https://www.w3schools.com/js/js_hoisting.asp Hoisting is JavaScript's default behavior of moving all declarations to the top of the current scope (to the top of the current script or the current function). https://blog.mariusschulz.com/2016/01/06/function-definitions-in-javascript Function Declaration Function Expression
  12. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/super
  13. https://www.w3schools.com/js/js_object_constructors.asp function Person(first, last, age, eye) { this.firstName = first; this.lastName = last; this.age = age; this.eyeColor = eye; } Person.prototype.walk = function(meter){ // Move person 'meter' meters forward } var astrophysicist = new Person('Neil', 'Tyson', 59, 'Dark Brown')
  14. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype https://www.w3schools.com/js/js_object_prototypes.asp
  15. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
  16. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
  17. class Person { constructor(first, last) { this.firstName = first; this.lastName = last; } sayHi() { console.info('Hi ' + this.firstName + ' Person'); } sayHello() { console.info('Hello ' + this.firstName + ' Person'); } } class astrophysicist extends Person{ constructor(first, last){ super(first, last); } https://javascript.info/prototype-inheritance static fullName(first, last){ console.info(first + " " + last); } sayHi(){ super.sayHi(); console.info('Hi ' + this.firstName + ' astrophysicist'); } } var neil = new astrophysicist('Neil', 'Tyson'); astrophysicist.fullName('stephen', 'hawking') neil.sayHi(); neil.sayHello();
  18. Read from page no. 25 to page no. 29 - The Principles of object-oriented javascript - by Nicholas C. Zakas
  19. Read from page no. 25 to page no. 29 - The Principles of object-oriented javascript - by Nicholas C. Zakas function sayNameForAll(label) { console.log(label + " : " + this.name); } var tyson = { name: "Tyson" }; var hawking = { name: "Hawking" }; sayNameForAll.call(tyson, 'Family Name(Call)'); sayNameForAll.call(hawking, 'My Family Name(Call)'); sayNameForAll.apply(tyson, ['Family Name(Apply)']); sayNameForAll.apply(hawking, ['My Family Name(Apply)']); var callTyson = sayNameForAll.bind(tyson); var callHawking = sayNameForAll.bind(hawking); callTyson('Family Name(Bind)'); callHawking('My Family Name(Bind)');
  20. https://dev.to/sarah_chima/var-let-and-const--whats-the-difference-69e
  21. https://dev.to/sarah_chima/var-let-and-const--whats-the-difference-69e
  22. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals var cosmologist = { name: "Hawking" } var books = { no: 7, famousOne: "A Brief History of Time"} var brief = `${books.famousOne} is a popular-science book on cosmology by ${cosmologist.name}`; var message = books.famousOne + "\n" + "is a popular-science book on cosmology by " + cosmologist.name;
  23. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment const cosmologist = { firstName: 'stephen', lastName: 'Hawking' } const { firstName, lastName } = cosmologist; console.info(firstName); console.info(lastName); var books = ['A Brief History of Time', 'The Universe in a Nutshell', 'On the Shoulders of Giants']; const [famousOne, ...restBooks] = books; console.info(famousOne); console.info(restBooks);
  24. https://medium.com/ecmascript-2015/default-rest-spread-f3ab0d2e0a5e function add(a, b) { return a + (b || 0); } function add(a, b = 0) { return a + b; }
  25. https://medium.com/ecmascript-2015/default-rest-spread-f3ab0d2e0a5e https://codingwithspike.wordpress.com/2016/06/11/javascript-rest-spread-operators/ function add() { var result = 0; for (var i = 0; i < arguments.length; i++) { result += arguments[i]; } return result; } function sum(...numbers) { var result = 0; numbers.forEach(function (number) { result += number; }); return result; }
  26. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax https://codingwithspike.wordpress.com/2016/06/11/javascript-rest-spread-operators/ Different Spread When using spread, you are expanding a single variable into more: Rest When using rest arguments, you are collapsing all remaining arguments of a function into one array: https://stackoverflow.com/questions/33898512/spread-operator-vs-rest-parameter-in-es2015-es6?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
  27. https://babeljs.io/repl/
  28. https://github.com/getify/You-Dont-Know-JS
  29. https://developer.mozilla.org/en-US/docs/Web/Web_Components https://github.com/mdn/web-components-examples/tree/master/edit-word https://github.com/praveenpuglia/shadow-dom-in-depth https://www.youtube.com/watch?v=SDs4xmMcVS4 https://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/
  30. https://www.webcomponents.org/introduction https://www.polymer-project.org/
  31. https://medium.com/@dan.shapiro1210/understanding-component-based-architecture-3ff48ec0c238 https://developer.telerik.com/featured/front-end-application-frameworks-component-architectures/
  32. https://medium.com/@dan.shapiro1210/understanding-component-based-architecture-3ff48ec0c238
  33. https://en.wikipedia.org/wiki/Single-page_application https://medium.com/@NeotericEU/single-page-application-vs-multiple-page-application-2591588efe58
  34. https://en.wikipedia.org/wiki/React_(JavaScript_library) https://blog.risingstack.com/the-history-of-react-js-on-a-timeline/
  35. React is trying to solve this problem by using something called virtual DOM; a DOM kept in memory. Any view changes are first reflected to virtual DOM, then an efficient diff algorithm compares the previous and current states of the virtual DOM and calculates the best way (minimum amount of updates needed) to apply these changes. Finally those updates are applied to the DOM to ensure minimum read/write time. This is the main reason behind React’s high performance
  36. https://codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2
  37. https://codeburst.io/declarative-vs-imperative-programming-a8a7c93d9ad2
  38. https://www.exclamationlabs.com/blog/the-case-for-unidirectional-data-flow/
  39. http://reactkungfu.com/2015/10/the-difference-between-virtual-dom-and-dom/ https://hackernoon.com/virtual-dom-in-reactjs-43a3fdb1d130
  40. https://hackernoon.com/virtual-dom-in-reactjs-43a3fdb1d130 http://jsclass.jcoglan.com/observable.html
  41. https://reactjs.org/docs/introducing-jsx.html
  42. https://reactjs.org/docs/introducing-jsx.html
  43. https://reactjs.org/docs/introducing-jsx.html
  44. https://reactjs.org/docs/introducing-jsx.html
  45. Wrtie application using react.createEllemet at html page after reference react and react dom scripts Introduce JSX file First Component print string how to bind Embedding Expression
  46. React.createElement(name, props, children) Show an example about React.createElement
  47. Introduce JSX file First Component print string how to bind Embedding Expression
  48. https://reactjs.org/docs/components-and-props.html
  49. https://reactjs.org/docs/components-and-props.html
  50. https://reactjs.org/docs/components-and-props.html ReactDOM.render(
 React.createElement(
 Welcome, { name: 'React' }
 ),
 document.getElementById('root')
 );
  51. https://reactjs.org/docs/components-and-props.html https://reactjs.org/docs/typechecking-with-proptypes.html
  52. A demo to show how setState works Change text (onChange) example, check after change directly (setState Async) Composing Components Extracting Components static defaultProps import PropTypes from 'prop-types'; MyComponent.propTypes = { children: PropTypes.element.isRequired }; User Card
  53. https://hackernoon.com/reactjs-component-lifecycle-methods-a-deep-dive-38275d9d13c0 https://www.youtube.com/watch?v=Oioo0IdoEls
  54. https://hackernoon.com/reactjs-component-lifecycle-methods-a-deep-dive-38275d9d13c0 https://www.youtube.com/watch?v=Oioo0IdoEls
  55. https://reactjs.org/docs/react-component.html
  56. https://reactjs.org/docs/react-component.html
  57. https://reactjs.org/docs/handling-events.html
  58. How to handle Events setState Again Life cycle Functional and Class Components
  59. https://reactjs.org/docs/conditional-rendering.html
  60. https://reactjs.org/docs/lists-and-keys.html
  61. https://reactjs.org/docs/lists-and-keys.html
  62. Create List of users Render Images and Name Add custom styles
  63. https://reactjs.org/docs/forms.html
  64. https://reactjs.org/docs/forms.html
  65. https://reactjs.org/docs/forms.html
  66. https://reactjs.org/docs/uncontrolled-components.html
  67. File input to get files using refs Controlled components example Textbox Textarea
  68. https://gerardnico.com/lang/javascript/react/shared_state
  69. Shared text boxes One parent to components And introduce component at separates files
  70. Shared text boxes One parent to components Celsius & fahrenheit
  71. Think how to manage this problem using you mind
  72. Meaning of reducer? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce They are used to reduce a collection of values down to a single value.
  73. https://redux.js.org/basics/actions
  74. https://redux.js.org/basics/reducers
  75. https://redux.js.org/basics/reducers
  76. https://redux.js.org/basics/store
  77. Full React+Redux Demo Middleware Demo
  78. Full React+Redux Demo Middleware Demo
  79. https://jsonplaceholder.typicode.com/ Demo for ajax call Get list and render it.
  80. https://reacttraining.com/react-router/web/example/basic
  81. Lab on react-router and ajax calls Redux Application
  82. Follow Specific File Structure Functional VS Class Components Ask your self? When to use redux Redux Store Design Redux plugins
  83. Navigation menu Real-time search