Interview Q&A / React
React interview questions
Rendering, state, hooks, keys and effects, explained with small examples.
Prefer rapid revision? Practise React short interview answers →
- When should you use Context instead of prop drilling or a state management library?
Pass props when only a few levels need the data. Use Context for values many components read but that change rarely, such as theme, language or the logged-in user. Reach for a state library when shared state is large, updates often, or needs tools like selectors and devtools.
IntermediateIn-depth3 min read - How do createContext, Provider and useContext work together?
createContext makes a context object with a default value. A Provider higher in the tree supplies the real value. Any component below it calls useContext(MyContext) to read the nearest provider's value, with no props passed through the middle layers.
BeginnerQuick answer1 min read