Need Assistance?

support@tutorialshub.in

Context and State Management

Using Context

React.js Free Lesson
5 min read
ADVERTISEMENT

What is Context?

Context lets a value be shared with components deeper in the component tree without manually passing that value through every intermediate component.

When Context Is Useful

  • Authentication information.
  • Theme settings.
  • Locale or language settings.
  • Application configuration.
  • Shared state for a specific part of the application.

Do Not Overuse Context

Context is not automatically the best solution for every piece of state. If only one or two components need a value, normal props may be simpler and easier to understand.

ADVERTISEMENT