DEV Community

Mathu varshtih
Mathu varshtih

Posted on

React Hook: useContext

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

Top comments (0)