Hi we used the context to stop the prop drilling now the question
What is prop drilling
prop drilling is the concept when we data pass the three level of hierarchy
App => card=> user=>date
here in the app component we passed the data in app comp. to card comp. and user comp. and date comp.
What is context
context api is used the managed the stated and share the state across the nested compon.
Here we see that the we create a context and ok you think like a box and and structute of box i take example on this simple there are some property
you have variable of context in this picture i take the User
Note used value={{youstate,props,function}}
Provider
consumer
what are state and data you pass the provider you pass the function, data etc
and consumer whose compon used this datac
Now we used the Usecontext hook to used the consuming
What is useContext
use context allow to access the context value provide by a context object direct in the next function component
Top comments (0)