Your application has deeply nested components, and you want to avoid prop drilling. Which React feature would you use to pass user authentication status to all these nested components?

  • Context API
  • Higher-Order Components (HOCs)
  • React Hooks (useState, useContext)
  • Redux
To avoid prop drilling in deeply nested components, you can use the Context API. Context allows you to share data, like user authentication status, across components without the need to pass it explicitly through props. While Higher-Order Components (HOCs), Redux, and React Hooks are useful in various scenarios, Context API is specifically designed for this purpose, making it the most suitable choice for passing data down to deeply nested components.
Add your answer
Loading...

Leave a comment

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