โ† React Native
#7 most askedVery commonMediumState & hooks

Avoiding unnecessary re-renders

New to State & hooks? Learn it from scratch first
State, Events & Reducers โ†’
๐Ÿข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.
I was asked this

A screen feels slow because list rows re-render on every keystroke. How do you find and fix unnecessary re-renders?

๐Ÿ”ฎ Predict the output

// Shallow comparison, like React.memo
const sameProps = (a, b) => Object.keys(a).every((k) => a[k] === b[k]);
const handler = () => {};
const render1 = { title: "Hi", onPress: handler, style: { padding: 8 } };
const render2 = { title: "Hi", onPress: handler, style: { padding: 8 } };
console.log(sameProps(render1, render2));
render2.style = render1.style;
console.log(sameProps(render1, render2));

๐ŸŽค Answer it out loud, then check yourself

Say your answer as if the interviewer is listening (30โ€“90 seconds). Then reveal what a strong answer covers and tick what you said.

    Answer out loud first, then compare.
    Want to rehearse it?
    Answer this to the AI interviewer and get a verdict โ†’