Put in order · JavaScript and React course · Module 4: Context API and useReducer
When to Use Context Instead of Props
Arrange when to switch from props to Context API - from simplest case:
Items to put in order
- Data needed in many unrelated components - Context API
- Data through 3+ levels - consider Context API
- Data through 2 levels - props or component composition
- Data passed to a direct child - regular props
- Global data (theme, auth, locale) - Context API is mandatory
You can check the correct answer by solving this task in the CodeWorlds game.