SlideShare a Scribd company logo
3
Most read
4
Most read
Piyush Jamwal
useContext Hook
React js
Youtube video: https://youtu.be/eVFkFN5S43k
Subscribe my channel
Hooks ?
Hooks are special functions in functional react components, starting with the
pre
fi
x ‘use’.

These functions are analogous to various methods provided by react class
components

For example: we have useE
ff
ect hook which can mimic various react class
component life cycles like componentDidMount, componentDidUpdate.

We have useState analogous to react class component States.
Without useContext Hook
component 2
component 1
Props
component 3
component 4
Props
Props
function Component2(props) {


return <Component3 text={props.text} />;


}


function Component1(props) {


return <Component2 text={props.text} />;


}


function Component3(props) {


return <Component4 text={props.text} />;


}


function Component4(props) {


return <input type="text" value=
{props.text} />


}
Using useContext Hook
component 2
component 1
component 3
component 4
Context Provider Component
<contextObject.Provider value={<input
type="text" value={text}></input>}>


<Component1 />


</contextObject.Provider>


const value = React.useContext(contextObject);


<contextObject.Consumer>


{value=> <input type="text"
value={value}></input>}


</contextObject.Consumer>


For Consuming the data there are two methods
Thank you 

Please subscribe Growing Scientist and like the video

More Related Content

What's hot (20)

PDF
Understanding React hooks | Walkingtree Technologies
Walking Tree Technologies
 
PPTX
React js programming concept
Tariqul islam
 
PDF
ReactJS presentation
Thanh Tuong
 
PDF
Introduction to Redux
Ignacio Martín
 
PPTX
React Hooks
Erez Cohen
 
PDF
React and redux
Mystic Coders, LLC
 
PPTX
Introduction to React JS for beginners
Varun Raj
 
PPTX
Understanding react hooks
Maulik Shah
 
PPTX
Intro to React
Eric Westfall
 
PDF
React js
Rajesh Kolla
 
PPTX
Reactjs
Neha Sharma
 
PPTX
Its time to React.js
Ritesh Mehrotra
 
PPTX
React js
Oswald Campesato
 
PDF
Workshop 21: React Router
Visual Engineering
 
PPT
React js
Jai Santhosh
 
PPTX
Introduction to react_js
MicroPyramid .
 
PDF
React new features and intro to Hooks
Soluto
 
PPTX
Introduction to React
Rob Quick
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
PDF
Basics of React Hooks.pptx.pdf
Knoldus Inc.
 
Understanding React hooks | Walkingtree Technologies
Walking Tree Technologies
 
React js programming concept
Tariqul islam
 
ReactJS presentation
Thanh Tuong
 
Introduction to Redux
Ignacio Martín
 
React Hooks
Erez Cohen
 
React and redux
Mystic Coders, LLC
 
Introduction to React JS for beginners
Varun Raj
 
Understanding react hooks
Maulik Shah
 
Intro to React
Eric Westfall
 
React js
Rajesh Kolla
 
Reactjs
Neha Sharma
 
Its time to React.js
Ritesh Mehrotra
 
Workshop 21: React Router
Visual Engineering
 
React js
Jai Santhosh
 
Introduction to react_js
MicroPyramid .
 
React new features and intro to Hooks
Soluto
 
Introduction to React
Rob Quick
 
ReactJS presentation.pptx
DivyanshGupta922023
 
Basics of React Hooks.pptx.pdf
Knoldus Inc.
 

Similar to React js use contexts and useContext hook (20)

PPTX
How to use UseContext Hook in React.pptx
BOSC Tech Labs
 
PDF
React JS Hooks Sheet .pdf
nishant078cs23
 
PDF
How to build a react native app with the help of react native hooks
Katy Slemon
 
PDF
React Hooks by Oleksandr Oleksiv Scalac
Scalac
 
PDF
How do we use hooks
Jim Liu
 
PDF
React hooks beyond hype
Magdiel Duarte
 
PDF
React.js hooks feb 23rd meetup
Jaikant Kumaran
 
PDF
React state management and side-effects – A Review of Hooks
IRJET Journal
 
PDF
React – Let’s “Hook” up
InnovationM
 
PPTX
Green Custard Friday Talk 21: React Hooks
Green Custard
 
PDF
React Back to the Future
500Tech
 
PDF
We Are Developers - Modern React (Suspense, Context, Hooks) - Roy Derks
Roy Derks
 
PPTX
React-JS.pptx
AnmolPandita7
 
PDF
React hooks Episode #1: An introduction.
ManojSatishKumar
 
PDF
Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019
Codemotion
 
PPTX
Hook me UP ( React Hooks Introduction)
Carlos Mafla
 
PDF
Introduction to React Hooks
Felicia O'Garro
 
PDF
State managment in a world of hooks
500Tech
 
PDF
Hello, React Hooks!
Heejong Ahn
 
PPTX
what is context API and How it works in React.pptx
BOSC Tech Labs
 
How to use UseContext Hook in React.pptx
BOSC Tech Labs
 
React JS Hooks Sheet .pdf
nishant078cs23
 
How to build a react native app with the help of react native hooks
Katy Slemon
 
React Hooks by Oleksandr Oleksiv Scalac
Scalac
 
How do we use hooks
Jim Liu
 
React hooks beyond hype
Magdiel Duarte
 
React.js hooks feb 23rd meetup
Jaikant Kumaran
 
React state management and side-effects – A Review of Hooks
IRJET Journal
 
React – Let’s “Hook” up
InnovationM
 
Green Custard Friday Talk 21: React Hooks
Green Custard
 
React Back to the Future
500Tech
 
We Are Developers - Modern React (Suspense, Context, Hooks) - Roy Derks
Roy Derks
 
React-JS.pptx
AnmolPandita7
 
React hooks Episode #1: An introduction.
ManojSatishKumar
 
Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019
Codemotion
 
Hook me UP ( React Hooks Introduction)
Carlos Mafla
 
Introduction to React Hooks
Felicia O'Garro
 
State managment in a world of hooks
500Tech
 
Hello, React Hooks!
Heejong Ahn
 
what is context API and How it works in React.pptx
BOSC Tech Labs
 
Ad

Recently uploaded (20)

PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PPT
Testing and final inspection of a solar PV system
MuhammadSanni2
 
PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
PPTX
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PPTX
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Testing and final inspection of a solar PV system
MuhammadSanni2
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
Distribution reservoir and service storage pptx
dhanashree78
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Design Thinking basics for Engineers.pdf
CMR University
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Ad

React js use contexts and useContext hook

  • 1. Piyush Jamwal useContext Hook React js Youtube video: https://youtu.be/eVFkFN5S43k Subscribe my channel
  • 2. Hooks ? Hooks are special functions in functional react components, starting with the pre fi x ‘use’. These functions are analogous to various methods provided by react class components For example: we have useE ff ect hook which can mimic various react class component life cycles like componentDidMount, componentDidUpdate. We have useState analogous to react class component States.
  • 3. Without useContext Hook component 2 component 1 Props component 3 component 4 Props Props function Component2(props) { return <Component3 text={props.text} />; } function Component1(props) { return <Component2 text={props.text} />; } function Component3(props) { return <Component4 text={props.text} />; } function Component4(props) { return <input type="text" value= {props.text} /> }
  • 4. Using useContext Hook component 2 component 1 component 3 component 4 Context Provider Component <contextObject.Provider value={<input type="text" value={text}></input>}> <Component1 /> </contextObject.Provider> const value = React.useContext(contextObject); <contextObject.Consumer> {value=> <input type="text" value={value}></input>} </contextObject.Consumer> For Consuming the data there are two methods
  • 5. Thank you Please subscribe Growing Scientist and like the video