SlideShare a Scribd company logo
React JS: A Secret Preview
Prashant Sharma
https://www.linkedin.com/in/response2prashant
Agendas
1. Introduction
2. What is React JS?
3. What is Single Page Application?
4. Why React is better than other SPA?
5. React JS Setup
6. React JSX
7. ES6 Arrow Function
8. React Components
9. Component Life Cycle
10. Error Boundaries
11. React Higher Order Component (hoc)
12. Axios in React
to be continued….
12. Redux
13. Advantages of React JS
14. Disadvantages of React JS
● React is a front-end library developed by Facebook, in the year 2013.
● It is used for handling the view layer for web and mobile apps.
● ReactJS allows us to create reusable UI components.
● It is currently one of the most popular JavaScript libraries and has a
strong foundation and large community behind it.
Introduction
● React is a library for building composable user interfaces.
● It encourages the creation of reusable UI components, which present
data that changes over time.
● React abstracts away the DOM from you, offering a simpler
programming model and better performance.
● React can also render on the server using Node, and it can power
native apps using React Native.
● React implements one-way reactive data flow, which reduces the
boilerplate and is easier to reason about than traditional data binding.
What is React JS ?
What is Single Page Applications?
A single-page application is an app that works inside a browser and does
not require page reloading during use.
You are using this type of applications every day. These are for instance:
Gmail, Google Maps, Facebook and GitHub.
● There are various Single Page Applications Frameworks like Angularjs,
Reactjs and Vuejs.
● Angularjs is a MVC framework . Angularjs is complicated in comparison
to Reactjs and Vuejs but proper documentation available.
● Reactjs is a library not a framework and easy to learn but proper
documentation is not available.
Why React is better than other
SPAs?
...to be continue
● High level of flexibility and maximum of responsiveness.
● Vue js describes itself as “The Progressive JavaScript Frameworks”
and easy to learn in comparison to Angularjs and Reactjs.
● Lack of full english documentation.
● Vue js might have issues while integrating into huge projects.
Step: 1
Install node in your system
Step: 2
Open terminal type npm init react-app my-app
Step: 3
type cd my-app
Step: 4
type npm start
Step: 5
Now you can start building react app.
React configuration
React JSX
React uses JSX for templating instead of regular JavaScript. It is not
necessary to use it, however, following are some pros that come with it.
1. It is faster because it performs optimization while compiling code to
JavaScript.
2. It is also type-safe and most of the errors can be caught during
compilation.
3. It makes it easier and faster to write templates, if you are familiar with
HTML.
...to be continued
import React, {Component} from 'react';
import Layout from './components/Layout/Layout.js';
import BurgerBuilder from './containers/BurgerBuilder/BurgerBuilder';
import { BrowserRouter, Route, link} from 'react-router-dom';
class App extends Component {
render() {
return (
<div>
<BrowserRouter>
<Layout>
<Route path="/" exact component={BurgerBuilder} />
</Layout>
</BrowserRouter>
</div>
);
}
}
export default App;
ES6 Arrow Function
arrowfunctionExample = () => {
return(
<div>Something</div>
);
}
Arrow function single parameter syntax:
arrowfunctionExample = a => a*a;
Arrow function double parameter syntax:
arrowfunctionExample = (a,b) => a*b;
Arrow function with JSX:
arrowfunctionExample = () => (<div>Something</div>);
….to be continued
Arrow function with multiple line:
arrowfunctionExample = (a, b) =>{
const c = a+b;
return (
<div>Something {c}</div>
);
}
React Components
There are basically two types of component are used:
1. Stateful component
2. Stateless component
...to be continued
Stateful components:
import Backdrop from ‘backdrop’;
class Person extends Component {
state={
count: 0
}
render(){
return(
<div>
{this.state.count
<Backdrop show=”true” />
</div>);
}
}
export default Person:
...to be continued
Stateless components:
Stateless components have not their own state always dependant upon
another component. These components are reusable components.
const backdrop = (props) => (
props.show
?<div className={classes.Backdrop} onClick={props.clicked}></div>
: null
);
React Component Lifecycle
● We need more control over the stages that a component goes
through.
● The process where all these stages are involved is called the
component’s lifecycle and every React component goes through it.
● React provides several methods that notify us when certain stage of
this process occurs.
● These methods are called the component’s lifecycle methods and
they are invoked in a predictable order.
...to be continued
Basically all the React component’s lifecyle methods can be split in four
phases: initialization, mounting, updating and unmounting. Let’s take a
closer look at each one of them.
Initialization
The initialization phase is where we define defaults and initial values for
this.props and this.state by implementing getDefaultProps() and
getInitialState() respectively.
...to be continued
Mounting
Mounting is the process that occurs when a component is being inserted
into the DOM. This phase has two methods that we can hook up with:
componentWillMount() and componentDidMount().
componentWillMount() method is first called in this phase.
componentDidMount() is invoked second in this phase.
...to be continued
Updating
There are also methods that will allow us to execute code relative to when
a component’s state or properties get updated. These methods are part of
the updating phase and are called in the following order:
componentWillReceiveProps()
shouldComponentUpdate()
componentWillUpdate()
render()
componentDidUpdate()
When received new
props from the parent.
...to be continued
Unmounting
In this phase React provide us with only one method:
● componentWillUnmount()
It is called immediately before the component is unmounted
from the DOM.
Error Boundaries
● A JavaScript error in a part of the UI shouldn’t break the whole app.
● To solve this problem for React users, React 16 introduces a new
concept of an “error boundary”.
● Error boundaries are React components that catch JavaScript errors
anywhere in their child component tree, log those errors, and display a
fallback UI instead of the component tree that crashed.
● Error boundaries catch errors during rendering, in lifecycle methods,
and in constructors of the whole tree below them.
...to be continued
class ErroBoundary extends React.Component{
state= {
hasError: false
}
componentDidCatch(error, info){
//Display fallback, UI
this,setState({hasError:true});
// You can also log error to an error reporting service
logErrorToMyService(error, info);
}
render(){
if(this.state.hasError){
return (<div>Something went wrong</div>);
}
return this.props.children;
}
}
...to be continued
Then you can use it as a regular component
<ErrorBoundary>
<MyComponent />
</ErrorBoundary>
React Higher Order Component
● A higher-order component in React is a pattern used to share common
functionality between components without repeating code.
● A higher-order component is actually not a component though, it is a
function.
● A HOC function takes a component as an argument and returns a
component.
● It transforms a component into another component and adds
additional data or functionality.
...to be continued
const NewComponent = (BaseComponent) => {
// ... create new component from old one and update
return UpdatedComponent
}
Axios in React
● Every project needs to interact with a REST API at some stage.
● Axios provides interaction with REST API.
● With the help of AXIOS you can send GET, POST, PUT and DELETE
request to the REST API and render response to our app.
● Axios is promise based.
What is Redux?
Redux is a predictable state container for JavaScript apps. Redux
uses this concept of uni-directional data flow:
● The application has a central /root state.
● A state change triggers View updates.
● Only special functions can change the state.
● A user interaction triggers these special, state changing functions.
● Only one change takes place at a time.
...to be continued
Advantages of React JS
1. Virtual DOM in ReactJS makes user experience better and
developer’s work faster.
2. Permission to reuse React components significantly saves time.
3. One-direction data flow in ReactJS provides a stable code.
4. An open-source library: constantly developing and open to
contributions.
Disadvantages of React
1. High pace of development.
2. Poor documentation.
3. ‘HTML in my JavaScript!’ – JSX as a barrier.
Thank you

More Related Content

What's hot (20)

PPTX
Its time to React.js
Ritesh Mehrotra
 
PDF
ReactJS presentation
Thanh Tuong
 
PPTX
Introduction to React JS for beginners
Varun Raj
 
PDF
React js
Rajesh Kolla
 
PPTX
Introduction to React JS
Arnold Asllani
 
PPTX
What is component in reactjs
manojbkalla
 
PDF
Introduction to Redux
Ignacio Martín
 
PPTX
Introduction to React
Rob Quick
 
PPTX
Intro to React
Eric Westfall
 
PPTX
React js programming concept
Tariqul islam
 
PPTX
React workshop
Imran Sayed
 
PDF
React JS - Introduction
Sergey Romaneko
 
PDF
React and redux
Mystic Coders, LLC
 
PPTX
React js
Oswald Campesato
 
PDF
An introduction to React.js
Emanuele DelBono
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
PDF
Understanding react hooks
Samundra khatri
 
PDF
Workshop 21: React Router
Visual Engineering
 
Its time to React.js
Ritesh Mehrotra
 
ReactJS presentation
Thanh Tuong
 
Introduction to React JS for beginners
Varun Raj
 
React js
Rajesh Kolla
 
Introduction to React JS
Arnold Asllani
 
What is component in reactjs
manojbkalla
 
Introduction to Redux
Ignacio Martín
 
Introduction to React
Rob Quick
 
Intro to React
Eric Westfall
 
React js programming concept
Tariqul islam
 
React workshop
Imran Sayed
 
React JS - Introduction
Sergey Romaneko
 
React and redux
Mystic Coders, LLC
 
An introduction to React.js
Emanuele DelBono
 
ReactJS presentation.pptx
DivyanshGupta922023
 
Understanding react hooks
Samundra khatri
 
Workshop 21: React Router
Visual Engineering
 

Similar to React JS: A Secret Preview (20)

PDF
Fundamental concepts of react js
StephieJohn
 
PDF
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
PDF
React JS Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
React Interview Question PDF By ScholarHat
Scholarhat
 
PPTX
Intro react js
Vijayakanth MP
 
PDF
Tech Talk on ReactJS
Atlogys Technical Consulting
 
PPTX
class based component.pptx
saikatsamanta49
 
PPTX
What are the components in React?
BOSC Tech Labs
 
PPTX
React - Start learning today
Nitin Tyagi
 
PPTX
React gsg presentation with ryan jung &amp; elias malik
Lama K Banna
 
PPTX
Presentation1
Kshitiz Rimal
 
PDF
Fundamental Concepts of React JS for Beginners.pdf
StephieJohn
 
PDF
Welcome to React & Flux !
Ritesh Kumar
 
PPTX
React Basic and Advance || React Basic
rafaqathussainc077
 
PPTX
Comparing Angular and React JS for SPAs
Jennifer Estrada
 
PPTX
React JS Interview Question & Answer
Mildain Solutions
 
PPTX
React JS .NET
Jennifer Estrada
 
PPTX
Introduction to ReactJS UI Web Dev .pptx
SHAIKIRFAN715544
 
PDF
FRONTEND DEVELOPMENT WITH REACT.JS
IRJET Journal
 
PDF
Copy of React_JS_Notes.pdf
suryanarayana272799
 
Fundamental concepts of react js
StephieJohn
 
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
React JS Interview Questions PDF By ScholarHat
Scholarhat
 
React Interview Question PDF By ScholarHat
Scholarhat
 
Intro react js
Vijayakanth MP
 
Tech Talk on ReactJS
Atlogys Technical Consulting
 
class based component.pptx
saikatsamanta49
 
What are the components in React?
BOSC Tech Labs
 
React - Start learning today
Nitin Tyagi
 
React gsg presentation with ryan jung &amp; elias malik
Lama K Banna
 
Presentation1
Kshitiz Rimal
 
Fundamental Concepts of React JS for Beginners.pdf
StephieJohn
 
Welcome to React & Flux !
Ritesh Kumar
 
React Basic and Advance || React Basic
rafaqathussainc077
 
Comparing Angular and React JS for SPAs
Jennifer Estrada
 
React JS Interview Question & Answer
Mildain Solutions
 
React JS .NET
Jennifer Estrada
 
Introduction to ReactJS UI Web Dev .pptx
SHAIKIRFAN715544
 
FRONTEND DEVELOPMENT WITH REACT.JS
IRJET Journal
 
Copy of React_JS_Notes.pdf
suryanarayana272799
 
Ad

More from valuebound (20)

PDF
Scaling Drupal for High Traffic Websites
valuebound
 
PDF
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
valuebound
 
PDF
How to Use DDEV to Streamline Your Drupal Development Process.
valuebound
 
PDF
How to Use AWS to Automate Your IT Operation| Valuebound
valuebound
 
PDF
How to Use Firebase to Send Push Notifications to React Native and Node.js Apps
valuebound
 
PDF
Mastering Drupal Theming
valuebound
 
PDF
The Benefits of Cloud Engineering
valuebound
 
PDF
Cloud Computing
valuebound
 
PDF
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
valuebound
 
PDF
Deep dive into ChatGPT
valuebound
 
PDF
Content Creation Solution | Valuebound
valuebound
 
PPTX
Road ahead for Drupal 8 contributed projects
valuebound
 
PPTX
Chatbot with RASA | Valuebound
valuebound
 
PDF
Drupal and Artificial Intelligence for Personalization
valuebound
 
PPTX
Drupal growth in last year | Valuebound
valuebound
 
PPTX
BE NEW TO THE WORLD "BRAVE FROM CHROME"
valuebound
 
PPTX
Event loop in browser
valuebound
 
PPTX
The Basics of MongoDB
valuebound
 
PPTX
Dependency Injection in Drupal 8
valuebound
 
PPTX
An Overview of Field Collection Views Module
valuebound
 
Scaling Drupal for High Traffic Websites
valuebound
 
Drupal 7 to Drupal 10 Migration A Fintech Strategic Blueprint (1).pdf
valuebound
 
How to Use DDEV to Streamline Your Drupal Development Process.
valuebound
 
How to Use AWS to Automate Your IT Operation| Valuebound
valuebound
 
How to Use Firebase to Send Push Notifications to React Native and Node.js Apps
valuebound
 
Mastering Drupal Theming
valuebound
 
The Benefits of Cloud Engineering
valuebound
 
Cloud Computing
valuebound
 
The Future of Cloud Engineering: Emerging Trends and Technologies to Watch in...
valuebound
 
Deep dive into ChatGPT
valuebound
 
Content Creation Solution | Valuebound
valuebound
 
Road ahead for Drupal 8 contributed projects
valuebound
 
Chatbot with RASA | Valuebound
valuebound
 
Drupal and Artificial Intelligence for Personalization
valuebound
 
Drupal growth in last year | Valuebound
valuebound
 
BE NEW TO THE WORLD "BRAVE FROM CHROME"
valuebound
 
Event loop in browser
valuebound
 
The Basics of MongoDB
valuebound
 
Dependency Injection in Drupal 8
valuebound
 
An Overview of Field Collection Views Module
valuebound
 
Ad

Recently uploaded (20)

PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 

React JS: A Secret Preview

  • 1. React JS: A Secret Preview Prashant Sharma https://www.linkedin.com/in/response2prashant
  • 2. Agendas 1. Introduction 2. What is React JS? 3. What is Single Page Application? 4. Why React is better than other SPA? 5. React JS Setup 6. React JSX 7. ES6 Arrow Function 8. React Components 9. Component Life Cycle 10. Error Boundaries 11. React Higher Order Component (hoc) 12. Axios in React
  • 3. to be continued…. 12. Redux 13. Advantages of React JS 14. Disadvantages of React JS
  • 4. ● React is a front-end library developed by Facebook, in the year 2013. ● It is used for handling the view layer for web and mobile apps. ● ReactJS allows us to create reusable UI components. ● It is currently one of the most popular JavaScript libraries and has a strong foundation and large community behind it. Introduction
  • 5. ● React is a library for building composable user interfaces. ● It encourages the creation of reusable UI components, which present data that changes over time. ● React abstracts away the DOM from you, offering a simpler programming model and better performance. ● React can also render on the server using Node, and it can power native apps using React Native. ● React implements one-way reactive data flow, which reduces the boilerplate and is easier to reason about than traditional data binding. What is React JS ?
  • 6. What is Single Page Applications? A single-page application is an app that works inside a browser and does not require page reloading during use. You are using this type of applications every day. These are for instance: Gmail, Google Maps, Facebook and GitHub.
  • 7. ● There are various Single Page Applications Frameworks like Angularjs, Reactjs and Vuejs. ● Angularjs is a MVC framework . Angularjs is complicated in comparison to Reactjs and Vuejs but proper documentation available. ● Reactjs is a library not a framework and easy to learn but proper documentation is not available. Why React is better than other SPAs?
  • 8. ...to be continue ● High level of flexibility and maximum of responsiveness. ● Vue js describes itself as “The Progressive JavaScript Frameworks” and easy to learn in comparison to Angularjs and Reactjs. ● Lack of full english documentation. ● Vue js might have issues while integrating into huge projects.
  • 9. Step: 1 Install node in your system Step: 2 Open terminal type npm init react-app my-app Step: 3 type cd my-app Step: 4 type npm start Step: 5 Now you can start building react app. React configuration
  • 10. React JSX React uses JSX for templating instead of regular JavaScript. It is not necessary to use it, however, following are some pros that come with it. 1. It is faster because it performs optimization while compiling code to JavaScript. 2. It is also type-safe and most of the errors can be caught during compilation. 3. It makes it easier and faster to write templates, if you are familiar with HTML.
  • 11. ...to be continued import React, {Component} from 'react'; import Layout from './components/Layout/Layout.js'; import BurgerBuilder from './containers/BurgerBuilder/BurgerBuilder'; import { BrowserRouter, Route, link} from 'react-router-dom'; class App extends Component { render() { return ( <div> <BrowserRouter> <Layout> <Route path="/" exact component={BurgerBuilder} /> </Layout> </BrowserRouter> </div> ); } } export default App;
  • 12. ES6 Arrow Function arrowfunctionExample = () => { return( <div>Something</div> ); }
  • 13. Arrow function single parameter syntax: arrowfunctionExample = a => a*a; Arrow function double parameter syntax: arrowfunctionExample = (a,b) => a*b; Arrow function with JSX: arrowfunctionExample = () => (<div>Something</div>);
  • 14. ….to be continued Arrow function with multiple line: arrowfunctionExample = (a, b) =>{ const c = a+b; return ( <div>Something {c}</div> ); }
  • 15. React Components There are basically two types of component are used: 1. Stateful component 2. Stateless component
  • 16. ...to be continued Stateful components: import Backdrop from ‘backdrop’; class Person extends Component { state={ count: 0 } render(){ return( <div> {this.state.count <Backdrop show=”true” /> </div>); } } export default Person:
  • 17. ...to be continued Stateless components: Stateless components have not their own state always dependant upon another component. These components are reusable components. const backdrop = (props) => ( props.show ?<div className={classes.Backdrop} onClick={props.clicked}></div> : null );
  • 18. React Component Lifecycle ● We need more control over the stages that a component goes through. ● The process where all these stages are involved is called the component’s lifecycle and every React component goes through it. ● React provides several methods that notify us when certain stage of this process occurs. ● These methods are called the component’s lifecycle methods and they are invoked in a predictable order.
  • 19. ...to be continued Basically all the React component’s lifecyle methods can be split in four phases: initialization, mounting, updating and unmounting. Let’s take a closer look at each one of them. Initialization The initialization phase is where we define defaults and initial values for this.props and this.state by implementing getDefaultProps() and getInitialState() respectively.
  • 20. ...to be continued Mounting Mounting is the process that occurs when a component is being inserted into the DOM. This phase has two methods that we can hook up with: componentWillMount() and componentDidMount(). componentWillMount() method is first called in this phase. componentDidMount() is invoked second in this phase.
  • 21. ...to be continued Updating There are also methods that will allow us to execute code relative to when a component’s state or properties get updated. These methods are part of the updating phase and are called in the following order: componentWillReceiveProps() shouldComponentUpdate() componentWillUpdate() render() componentDidUpdate() When received new props from the parent.
  • 22. ...to be continued Unmounting In this phase React provide us with only one method: ● componentWillUnmount() It is called immediately before the component is unmounted from the DOM.
  • 23. Error Boundaries ● A JavaScript error in a part of the UI shouldn’t break the whole app. ● To solve this problem for React users, React 16 introduces a new concept of an “error boundary”. ● Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed. ● Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.
  • 24. ...to be continued class ErroBoundary extends React.Component{ state= { hasError: false } componentDidCatch(error, info){ //Display fallback, UI this,setState({hasError:true}); // You can also log error to an error reporting service logErrorToMyService(error, info); } render(){ if(this.state.hasError){ return (<div>Something went wrong</div>); } return this.props.children; } }
  • 25. ...to be continued Then you can use it as a regular component <ErrorBoundary> <MyComponent /> </ErrorBoundary>
  • 26. React Higher Order Component ● A higher-order component in React is a pattern used to share common functionality between components without repeating code. ● A higher-order component is actually not a component though, it is a function. ● A HOC function takes a component as an argument and returns a component. ● It transforms a component into another component and adds additional data or functionality.
  • 27. ...to be continued const NewComponent = (BaseComponent) => { // ... create new component from old one and update return UpdatedComponent }
  • 28. Axios in React ● Every project needs to interact with a REST API at some stage. ● Axios provides interaction with REST API. ● With the help of AXIOS you can send GET, POST, PUT and DELETE request to the REST API and render response to our app. ● Axios is promise based.
  • 29. What is Redux? Redux is a predictable state container for JavaScript apps. Redux uses this concept of uni-directional data flow: ● The application has a central /root state. ● A state change triggers View updates. ● Only special functions can change the state. ● A user interaction triggers these special, state changing functions. ● Only one change takes place at a time.
  • 31. Advantages of React JS 1. Virtual DOM in ReactJS makes user experience better and developer’s work faster. 2. Permission to reuse React components significantly saves time. 3. One-direction data flow in ReactJS provides a stable code. 4. An open-source library: constantly developing and open to contributions.
  • 32. Disadvantages of React 1. High pace of development. 2. Poor documentation. 3. ‘HTML in my JavaScript!’ – JSX as a barrier.