React interview questions
BetaRendering, hooks, state, effects, performance and the mental model behind them.
Subtopics
- Components, props & JSX8
- State & useState6
- Effects & useEffect6
- Rendering & reconciliation6
- Keys & lists6
- Context & prop drilling6
- useMemo, useCallback & memo6
- useRef & DOM access6
- Custom hooks6
- Forms & controlled inputs6
- Data fetching & suspense6
- Error boundaries6
- Testing with React Testing Library6
Sample questions
- CodingJuniorComponents, props & JSX
Write
mergeDefaultProps(props, defaults). It returns a new plain object that has every key fromdefaults, overridden by any key present inpropswhose value is notundefined. Neither input object should be mutated. This is the logic behind default props: a caller who does not - CodingJuniorComponents, props & JSX
Write
buildClassName(base, conditional).baseis a string (possibly with several space-separated classes).conditionalis an object mapping class name to a boolean. Return a single space-separated class string containingbase's classes followed by every key ofconditionalwhose - TheoryJuniorComponents, props & JSX
In plain terms: what is a React component, and what are props? Give me a concrete example of a parent handing something to a child.
- TheoryJuniorComponents, props & JSX
You write
<Card title="Hi">text</Card>in a.jsxfile. What does that line actually turn into when the code runs, and why does a component have to return a single root node? - CodingJuniorContext & prop drilling
Write
composeProviderValues(values).valuesis an array of plain objects, representing a stack of nestedContext.Providervalues from outermost to innermost. Merge them into the single object a component deep in the tree would end up seeing if each provider spread the outer - TheoryJuniorContext & prop drilling
In plain terms: what is "prop drilling", and how does React Context give you a way around it?