Which hook allows functional components to consume context values?

  • useConsumer()
  • useContext()
  • useProvider()
  • useValue()
To allow functional components to consume context values in React, you use the useContext() hook. useContext() is a hook provided by React that enables functional components to access the data provided by a Context Provider. It simplifies the process of consuming context values and eliminates the need for a Context Consumer component, making it more convenient for functional components to access context data.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *