Professional Documents
Culture Documents
REACT
CONTEXT
API?
@codewithatia
Context API
In simpler terms context API
is state management tool
@codewithatia
If your're confused what
state is check one of my
posts called "useState"
@codewithatia
How it works?
All we need is to call
React.createContext(), it
returns provider & consumer
Provider Consumer
It provides It's used to
state to it's consume
children data.
@codewithatia
Here're 4 steps to use
context API
1. Create Context
2. Wrap in Context
Provider
3. Provide value
@codewithatia
Let's build a
simple app to
understand
context API
@codewithatia
Create Context
@codewithatia
Wrap in Provider
Wrap context in
provider &
also provide value to
context
@codewithatia
Read Value
useContext is simpler
to use
@codewithatia
Found it helpful? Follow for more
Need my help?
@codewithatia