With React 16.8, we got something called Hooks. Hooks allow developers to mimic class component functionality inside a functional component.

One of those hooks is the useContext hook which allows you to connect a functional component to a context.

const value = React.useContext(MyContext); 

From the documentation:

Accepts a context object (the value returned from React.createContext) and returns the current context value for that context. The current context value is determined by the value prop of the nearest <MyContext.Provider> above the calling component in the tree.

When the nearest <MyContext.Provider> above the component updates, this Hook will trigger a rerender with the latest context value passed to that MyContext provider.

Answer from user6612182 on Stack Overflow
๐ŸŒ
Medium
medium.com โ€บ @danfyfe โ€บ using-react-context-with-functional-components-153cbd9ba214
Using React Context with Functional Components | by Dan Fyfe | Medium
November 12, 2019 - Since this is a simple example, it may seem silly not to, but just imagine if you had a lot more going on and more components needed access to the same data. It can get real messy, real fast. Letโ€™s use Context! First lets make a file called thingsContext.js and fill it like so: import React from 'react'const ThingsContext = React.createContext({})export const ThingsProvider = ThingsContext.Providerexport default ThingsContext
๐ŸŒ
React
react.dev โ€บ reference โ€บ react โ€บ useContext
useContext โ€“ React
Here, the context value is a JavaScript object with two properties, one of which is a function. Whenever MyApp re-renders (for example, on a route update), this will be a different object pointing at a different function, so React will also have to re-render all components deep in the tree that call useContext(AuthContext).
Discussions

reactjs - How to access values from context in a separate functional component - Stack Overflow
I'm trying to build a simple light mode/dark mode into my app I saw this example on Material UI for light/dark mode but I'm not sure how I can get access to the value for when the user clicks More on stackoverflow.com
๐ŸŒ stackoverflow.com
reactjs - Context in "stateless" component? - Stack Overflow
0 How can I update the parent state by calling a function within a switch in my stateless component ? ... Is this alternative quadrupedal limb arrangement (two side limbs, one forelimb, and one hindlimb) evolutionarily plausible? ... What does Rom. 4:15b mean in context: "And where there is ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
reactjs - How to change context value in functional component? - Stack Overflow
export const statusCtxInit = { open: false, toggleOpen() { this.open = !this.open; } }; const StatusContext = React.createContext(statusCtxInit); export default StatusContext ... To use the values of my context I use useContext in my FC and it works when I get the value. function MyComp() { ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Can React Context be accessed outside of a react component?
if your app is big enough to warrant it, which it sounds like it is, you might consider moving off of context api onto redux. More on reddit.com
๐ŸŒ r/reactjs
4
3
October 5, 2020
๐ŸŒ
Medium
medium.com โ€บ nerd-for-tech โ€บ using-context-api-in-react-with-functional-components-dbc653c7d485
Using Context API in React with Functional Components | by Mr. Shadrack | Nerd For Tech | Medium
July 20, 2021 - Basically, Context API is designed to share โ€œglobalโ€ data that can be used in any part of your application without passing props down the component tree. Letโ€™s see how we can use Context API to build this simple user list application. I used create-react-app to bootstrap the project.
๐ŸŒ
DEV Community
dev.to โ€บ danireptor โ€บ guide-to-react-context-api-on-functional-components-1kj4
Guide to React Context API in Functional Components - DEV Community
January 24, 2023 - How to get data from context API The useContext hook is a way to access the current context value within a functional component in React. It allows you to access the value of a context object within a functional component.
๐ŸŒ
Kent C. Dodds
kentcdodds.com โ€บ blog โ€บ how-to-use-react-context-effectively
How to use React Context effectively
First, the useCount custom hook uses React.useContext to get the provided context value from the nearest CountProvider. However, if there is no value, then we throw a helpful error message indicating that the hook is not being called within a function component that is rendered within a ...
๐ŸŒ
ProgressiveWebNinja
progressivewebninja.com โ€บ home โ€บ blog โ€บ guide to react context with functional component using hooks
Guide to React Context with Functional Component using Hooks
April 6, 2022 - But can you use context with a functional component? Yes, we can use React Context with a Functional Component. By leveraging the useContext React Hook, we can subscribe to the context in any functional component.
Find elsewhere
๐ŸŒ
LogRocket
blog.logrocket.com โ€บ home โ€บ react context tutorial: complete guide with practical examples
React Context tutorial: Complete guide with practical examples - LogRocket Blog
February 19, 2025 - React Context is a great feature that enables you to manage and share state across the React application without needing to pass props through every level of the component tree. It is quite handy when you have a deeply nested component structure, ...
๐ŸŒ
Atomizedobjects
atomizedobjects.com โ€บ blog โ€บ react โ€บ how-to-use-usecontext-in-functional-components
How to use useContext in functional components? | Atomized Objects
December 4, 2020 - The plan here is to explain this ... react hook useContext is called inside of functional components and is used to gain access to a context that has been set somewhere upstream of the react component....
๐ŸŒ
Tania's Website
taniarascia.com โ€บ using context api in react (hooks and classes)
Using Context API in React (Hooks and Classes) | Tania Rascia's Website
April 25, 2019 - ... import React, { Component } ... <div>{props.name}</div> }} </UserConsumer> ) } } For functional components, you'll use useContext, such as in the example below....
๐ŸŒ
React
legacy.reactjs.org โ€บ docs โ€บ context.html
Context โ€“ React
A React component that subscribes to context changes. Using this component lets you subscribe to a context within a function component.
๐ŸŒ
Medium
medium.com โ€บ analytics-vidhya โ€บ react-how-to-use-context-with-functional-components-240a8ec4126a
React: How to Use Context with Functional Components | by Dunja Vesinger | Analytics Vidhya | Medium
September 15, 2020 - For easier navigation, you can group all such React Context instances in a common folder, separate from your React components. First, weโ€™ll take a look at defining the Context and then weโ€™ll go though where to place it and how to use it in your components. Similarly to state, Context is created using a createContext function.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ react-usecontext
How To Work with Context API in React and React Hooks | DigitalOcean
November 12, 2020 - The React Hook useContext() applies the same functionality in a streamlined, functional component body in one call.
๐ŸŒ
Refine
refine.dev โ€บ home โ€บ blog โ€บ tutorials โ€บ a guide to usecontext and react context api
A Guide to useContext and React Context API | Refine
October 31, 2024 - Keeping track of state and props can become cumbersome. The React Context API provides functionality for passing data from a parent component to its descendants without prop drilling.
๐ŸŒ
Dmitri Pavlutin
dmitripavlutin.com โ€บ react-context-and-usecontext
A Guide to React Context and useContext() Hook
February 2, 2023 - The first way, the one I recommend, is to use the useContext(Context) React hook: ... Open the demo. The hook returns the value of the context: value = useContext(Context). The hook also makes sure to re-render the component when the context value changes. The second way is by using a render function supplied as a child to Context.Consumer special component available on the context instance:
๐ŸŒ
Smashing Magazine
smashingmagazine.com โ€บ 2020 โ€บ 01 โ€บ introduction-react-context-api
An Introduction To Reactโ€™s Context API โ€” Smashing Magazine
January 13, 2020 - In this article, Yusuff Faruq will show you how to use Reactโ€™s Context API which allows you to manage global application states in your React apps without resorting to props drilling. In the process you will learn what the Context API is and the problem it solves, how to create Context and consuming it in both functional and class-based components, and when to use the Context API.
๐ŸŒ
Medium
medium.com โ€บ @darshana_18428 โ€บ how-to-use-react-context-api-with-functional-class-components-43feadf67492
How to use React Context API with Functional | Class Components | by Darshana Mallick | Medium
May 29, 2023 - In summary, React Context is a powerful feature that simplifies state management in React JS applications. React Context functional components can leverage the useContext hook, while class components can use the contextType property.