SlideShare a Scribd company logo
5
Most read
10
Most read
17
Most read
Presented By: Abhishek &
Saurabh Choudhary
Basics of React
Hooks
Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Join the session 5 minutes prior to
the session start time. We start on
time and conclude on time!
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Silent Mode
Keep your mobile devices in silent
mode, feel free to move out of
session in case you need to attend
an urgent call.
Avoid Disturbance
Avoid unwanted chit chat during
the session.
Our Agenda
01 React In Brief
02 Introduction to Hooks
03 Motivation behind Hooks
04 Types and Rules
05 Our First React Hook (useState Hook)
React In Brief
What is React ?
ā– React.js is an open-source JavaScript library that is used for building user
interfaces specifically for single-page applications.
ā– It is a component-based, front-end library responsible only for the
application’s view layer.
ā– React is not a framework that many of us think rather it is a User
Interface library that helps build beautiful and interactive UIs.
ā– React follows Declarative approach and is totally component-based
where we develop simple components and then combine them together
to build a complex UI.
Basics of React Hooks.pptx.pdf
Introduction to Hooks
What are Hooks ?
(Ques.) What is Hook in General terms ?
ā– Hooks are a new feature addition in React version 16.8
which allow you to use React features without having to
write a class
ā– Ex : State of a Component
(Ans.) a curved piece of metal, plastic, etc. that is used for
hanging or catching something
Motivation behind
Hooks
Why Hooks ?
āž¢ Understand how this keyword works in JavaScript
āž¢ Remember to bind event handlers in class components
āž¢ Classes don’t minify very well and make hot reloading very unreliable
Reason 1: Classes confuse both people and machines
Why Hooks ?
āž¢ There is no particular way to reuse stateful component logic
āž¢ HOC (Higher Order Component) and render props patterns do address this
problem but have to do some restructuring of components
āž¢ Makes the code harder to follow
āž¢ There is need a to share stateful logic in a better way
Reason 2: Itʼs hard to reuse stateful logic between components
Why Hooks ?
āž¢ Create components for complex scenarios such as data fetching and
subscribing to events
āž¢ Related code is not organized in one place
āž¢ Ex: Data fetching - In componentDidMount and componentDidUpdate
āž¢ Ex: Event Listeners - In componentDidMount and componentWillUnmount
āž¢ Because of stateful logic - Cannot break components into smaller ones
Reason 3: Complex components become hard to understand
Types and Rules of
Using Hooks
Types
āž¢ useState Hooks
āž¢ useEffect Hook
āž¢ useRef Hook
āž¢ useCallback Hook
āž¢ useMemo Hook
āž¢ useContext Hook
āž¢ useReducer Hook
Built-In Hooks :
Custom Hooks :
āž¢ You can create your own custom hooks if you have stateful logic that is needed by
multiple components in you application.
Rules
āž¢ Hooks are called only at the top level of a component.
āž¢ Do not call Hooks inside loops, conditions, or nested functions.
āž¢ Hooks are called only from React functional Components.
āž¢ Do not call Hooks from regular JavaScript functions.
There is one other way to call Hooks i.e. in your own custom Hooks
Hooks are normal JavaScript functions, but they impose some additional rules :
Let’s Implement our
First Hook
useState Hook
ā– The useState() is a hook that allows you to have state variables in
functional components.
ā– Basically useSate is the ability to encapsulate local state in a functional
component.
ā– The useSate hook is a special function that takes the initial state as an
argument and returns an array of two entries.
ā– You pass the initial state to this function and it returns a variable with the
current state value(not necessarily the initial state)and another function
to update this value.
How to implement useState()
Import useState() :-
ā– To use the useState hook, we first need to import it into our component.
import { useState } from ā€œreactā€;
Initialize useState() :-
ā– useState accepts an initial state and returns two values
āž¢ The current state
āž¢ A function that updates the state.
function FavoriteColor() {
const [ color, setColor ] = useState(ā€œ ā€);
Creating an array state with useState
ā– we destructure the return value of the useState() hook to get a variable
that contains the state array and a method for updating the state.
Demo
References
To learn more about Hooks follow the below links :
https://reactjs.org/docs/hooks-intro.html
You can find Free and Paid courses here :
https://reactjs.org/community/courses.html
Thank You !
Get in touch with us:
Lorem Studio, Lord Building
D4456, LA, USA

More Related Content

What's hot (20)

PPTX
React hooks
Sadhna Rana
Ā 
PPTX
React workshop
Imran Sayed
Ā 
PPTX
React hooks
Ramy ElBasyouni
Ā 
PPTX
Its time to React.js
Ritesh Mehrotra
Ā 
PPTX
Reactjs
Neha Sharma
Ā 
PDF
Introduction to Redux
Ignacio MartĆ­n
Ā 
PDF
React new features and intro to Hooks
Soluto
Ā 
PDF
ReactJS presentation
Thanh Tuong
Ā 
PDF
React hooks Episode #1: An introduction.
ManojSatishKumar
Ā 
PDF
React JS - Introduction
Sergey Romaneko
Ā 
PPTX
reactJS
Syam Santhosh
Ā 
PPTX
Introduction to react_js
MicroPyramid .
Ā 
PPTX
React-JS.pptx
AnmolPandita7
Ā 
PPTX
React Hooks
Erez Cohen
Ā 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
Ā 
PDF
Important React Hooks
Knoldus Inc.
Ā 
PDF
Introduction to React JS
Bethmi Gunasekara
Ā 
PPTX
Introduction to React JS for beginners
Varun Raj
Ā 
PDF
React and redux
Mystic Coders, LLC
Ā 
PPTX
Object Oriented Programming In JavaScript
Forziatech
Ā 
React hooks
Sadhna Rana
Ā 
React workshop
Imran Sayed
Ā 
React hooks
Ramy ElBasyouni
Ā 
Its time to React.js
Ritesh Mehrotra
Ā 
Reactjs
Neha Sharma
Ā 
Introduction to Redux
Ignacio MartĆ­n
Ā 
React new features and intro to Hooks
Soluto
Ā 
ReactJS presentation
Thanh Tuong
Ā 
React hooks Episode #1: An introduction.
ManojSatishKumar
Ā 
React JS - Introduction
Sergey Romaneko
Ā 
reactJS
Syam Santhosh
Ā 
Introduction to react_js
MicroPyramid .
Ā 
React-JS.pptx
AnmolPandita7
Ā 
React Hooks
Erez Cohen
Ā 
ReactJS presentation.pptx
DivyanshGupta922023
Ā 
Important React Hooks
Knoldus Inc.
Ā 
Introduction to React JS
Bethmi Gunasekara
Ā 
Introduction to React JS for beginners
Varun Raj
Ā 
React and redux
Mystic Coders, LLC
Ā 
Object Oriented Programming In JavaScript
Forziatech
Ā 

Similar to Basics of React Hooks.pptx.pdf (20)

PDF
React.js hooks feb 23rd meetup
Jaikant Kumaran
Ā 
PPTX
Understanding react hooks
Maulik Shah
Ā 
PDF
Understanding React hooks | Walkingtree Technologies
Walking Tree Technologies
Ā 
PDF
React hooks beyond hype
Magdiel Duarte
Ā 
PDF
React state management and side-effects – A Review of Hooks
IRJET Journal
Ā 
PDF
React – Let’s ā€œHookā€ up
InnovationM
Ā 
PDF
Hello, React Hooks!
Heejong Ahn
Ā 
PPTX
Green Custard Friday Talk 21: React Hooks
Green Custard
Ā 
PDF
React Hooks: Enhancing Functional Components with useState, useEffect, and Cu...
Akshat Pegwar
Ā 
PPTX
Will React Hooks replace Redux?
Trivikram Kamat
Ā 
PPTX
React Hooks Best Practices in 2022.pptx
BOSC Tech Labs
Ā 
PDF
Introduction to React Hooks
Felicia O'Garro
Ā 
PPTX
React Hooks
Joao Marins
Ā 
PDF
Importance of Hook in Recat Js.pdf
Nishaadequateinfosof
Ā 
PPTX
Pluginkla2019 - React Presentation
Angela Lehru
Ā 
PPTX
Hook me UP ( React Hooks Introduction)
Carlos Mafla
Ā 
PDF
How to build a react native app with the help of react native hooks
Katy Slemon
Ā 
PDF
How do we use hooks
Jim Liu
Ā 
PDF
Plain react, hooks and/or Redux ?
Jƶrn Dinkla
Ā 
PPTX
React API and Hooksfjhfhjfjhfhjfjfjhfjhf
DharnaAhuja1
Ā 
React.js hooks feb 23rd meetup
Jaikant Kumaran
Ā 
Understanding react hooks
Maulik Shah
Ā 
Understanding React hooks | Walkingtree Technologies
Walking Tree Technologies
Ā 
React hooks beyond hype
Magdiel Duarte
Ā 
React state management and side-effects – A Review of Hooks
IRJET Journal
Ā 
React – Let’s ā€œHookā€ up
InnovationM
Ā 
Hello, React Hooks!
Heejong Ahn
Ā 
Green Custard Friday Talk 21: React Hooks
Green Custard
Ā 
React Hooks: Enhancing Functional Components with useState, useEffect, and Cu...
Akshat Pegwar
Ā 
Will React Hooks replace Redux?
Trivikram Kamat
Ā 
React Hooks Best Practices in 2022.pptx
BOSC Tech Labs
Ā 
Introduction to React Hooks
Felicia O'Garro
Ā 
React Hooks
Joao Marins
Ā 
Importance of Hook in Recat Js.pdf
Nishaadequateinfosof
Ā 
Pluginkla2019 - React Presentation
Angela Lehru
Ā 
Hook me UP ( React Hooks Introduction)
Carlos Mafla
Ā 
How to build a react native app with the help of react native hooks
Katy Slemon
Ā 
How do we use hooks
Jim Liu
Ā 
Plain react, hooks and/or Redux ?
Jƶrn Dinkla
Ā 
React API and Hooksfjhfhjfjhfhjfjfjhfjhf
DharnaAhuja1
Ā 
Ad

More from Knoldus Inc. (20)

PPTX
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
Ā 
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
Ā 
PPTX
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
Ā 
PPTX
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
Ā 
PPTX
Java 17 features and implementation.pptx
Knoldus Inc.
Ā 
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
Ā 
PPTX
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
Ā 
PPTX
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
Ā 
PPTX
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
Ā 
PPTX
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
Ā 
PPTX
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
Ā 
PPTX
Introduction to Argo Rollouts Presentation
Knoldus Inc.
Ā 
PPTX
Intro to Azure Container App Presentation
Knoldus Inc.
Ā 
PPTX
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
Ā 
PPTX
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
Ā 
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
Ā 
PPTX
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
Ā 
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
Ā 
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
Ā 
PPTX
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
Ā 
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
Ā 
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
Ā 
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
Ā 
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
Ā 
Java 17 features and implementation.pptx
Knoldus Inc.
Ā 
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
Ā 
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
Ā 
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
Ā 
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
Ā 
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
Ā 
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
Ā 
Introduction to Argo Rollouts Presentation
Knoldus Inc.
Ā 
Intro to Azure Container App Presentation
Knoldus Inc.
Ā 
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
Ā 
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
Ā 
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
Ā 
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
Ā 
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
Ā 
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
Ā 
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
Ā 
Ad

Recently uploaded (20)

PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
Ā 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
Ā 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
Ā 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
Ā 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
Ā 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
Ā 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
Ā 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
Ā 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
Ā 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
Ā 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
Ā 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
Ā 
PDF
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
Ā 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
Ā 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
Ā 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
Ā 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
Ā 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
Ā 
PDF
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
Ā 
PDF
Are there government-backed agri-software initiatives in Limerick.pdf
giselawagner2
Ā 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
Ā 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
Ā 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
Ā 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
Ā 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
Ā 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
Ā 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
Ā 
Top Managed Service Providers in Los Angeles
Captain IT
Ā 
Blockchain Transactions Explained For Everyone
CIFDAQ
Ā 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
Ā 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
Ā 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
Ā 
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
Ā 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
Ā 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
Ā 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
Ā 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
Ā 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
Ā 
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
Ā 
Are there government-backed agri-software initiatives in Limerick.pdf
giselawagner2
Ā 

Basics of React Hooks.pptx.pdf

  • 1. Presented By: Abhishek & Saurabh Choudhary Basics of React Hooks
  • 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes Punctuality Join the session 5 minutes prior to the session start time. We start on time and conclude on time! Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Silent Mode Keep your mobile devices in silent mode, feel free to move out of session in case you need to attend an urgent call. Avoid Disturbance Avoid unwanted chit chat during the session.
  • 3. Our Agenda 01 React In Brief 02 Introduction to Hooks 03 Motivation behind Hooks 04 Types and Rules 05 Our First React Hook (useState Hook)
  • 5. What is React ? ā– React.js is an open-source JavaScript library that is used for building user interfaces specifically for single-page applications. ā– It is a component-based, front-end library responsible only for the application’s view layer. ā– React is not a framework that many of us think rather it is a User Interface library that helps build beautiful and interactive UIs. ā– React follows Declarative approach and is totally component-based where we develop simple components and then combine them together to build a complex UI.
  • 8. What are Hooks ? (Ques.) What is Hook in General terms ? ā– Hooks are a new feature addition in React version 16.8 which allow you to use React features without having to write a class ā– Ex : State of a Component (Ans.) a curved piece of metal, plastic, etc. that is used for hanging or catching something
  • 10. Why Hooks ? āž¢ Understand how this keyword works in JavaScript āž¢ Remember to bind event handlers in class components āž¢ Classes don’t minify very well and make hot reloading very unreliable Reason 1: Classes confuse both people and machines
  • 11. Why Hooks ? āž¢ There is no particular way to reuse stateful component logic āž¢ HOC (Higher Order Component) and render props patterns do address this problem but have to do some restructuring of components āž¢ Makes the code harder to follow āž¢ There is need a to share stateful logic in a better way Reason 2: Itʼs hard to reuse stateful logic between components
  • 12. Why Hooks ? āž¢ Create components for complex scenarios such as data fetching and subscribing to events āž¢ Related code is not organized in one place āž¢ Ex: Data fetching - In componentDidMount and componentDidUpdate āž¢ Ex: Event Listeners - In componentDidMount and componentWillUnmount āž¢ Because of stateful logic - Cannot break components into smaller ones Reason 3: Complex components become hard to understand
  • 13. Types and Rules of Using Hooks
  • 14. Types āž¢ useState Hooks āž¢ useEffect Hook āž¢ useRef Hook āž¢ useCallback Hook āž¢ useMemo Hook āž¢ useContext Hook āž¢ useReducer Hook Built-In Hooks : Custom Hooks : āž¢ You can create your own custom hooks if you have stateful logic that is needed by multiple components in you application.
  • 15. Rules āž¢ Hooks are called only at the top level of a component. āž¢ Do not call Hooks inside loops, conditions, or nested functions. āž¢ Hooks are called only from React functional Components. āž¢ Do not call Hooks from regular JavaScript functions. There is one other way to call Hooks i.e. in your own custom Hooks Hooks are normal JavaScript functions, but they impose some additional rules :
  • 17. useState Hook ā– The useState() is a hook that allows you to have state variables in functional components. ā– Basically useSate is the ability to encapsulate local state in a functional component. ā– The useSate hook is a special function that takes the initial state as an argument and returns an array of two entries. ā– You pass the initial state to this function and it returns a variable with the current state value(not necessarily the initial state)and another function to update this value.
  • 18. How to implement useState() Import useState() :- ā– To use the useState hook, we first need to import it into our component. import { useState } from ā€œreactā€; Initialize useState() :- ā– useState accepts an initial state and returns two values āž¢ The current state āž¢ A function that updates the state. function FavoriteColor() { const [ color, setColor ] = useState(ā€œ ā€);
  • 19. Creating an array state with useState ā– we destructure the return value of the useState() hook to get a variable that contains the state array and a method for updating the state.
  • 20. Demo
  • 21. References To learn more about Hooks follow the below links : https://reactjs.org/docs/hooks-intro.html You can find Free and Paid courses here : https://reactjs.org/community/courses.html
  • 22. Thank You ! Get in touch with us: Lorem Studio, Lord Building D4456, LA, USA