Menu

React Hook: useContext
📰

React Hook: useContext

DEV Community: react·Mathu varshtih·11 days ago
#27F3NTWF
#devtoreact#devto#dev#component#usecontext
Reading 0:00
15s threshold

Mathu varshtih

useContext is used to avoid the props drilling in react.

It helps us to share the data from one component to another component directly without passing props through the intermediate component.

It is done in 3 steps:
1. createContext() - create a context
2. Provider - provide the values
3. useContext() - consume the values