yoklainterview sim

Mobile Rn React Hooks State Management Interview Questions

75 verified Mobile Rn React Hooks State Management interview questions — solve with answers, learn from explanations, test yourself in a real simulation.

Try the real simulation →

Sample questions

Rn React Hooks State ManagementDifficulty 1
What does calling the setter returned by useState actually do?
  • aBlocks the JS thread until the native UI has redrawn.
  • bImmediately mutates the variable in place before the line finishes executing.
  • cWrites the value directly to AsyncStorage for persistence.
  • dSchedules a re-render with the new state value on the next render pass.
Explanation:useState's setter does not mutate anything synchronously. It tells React that this component's state changed, and React schedules a re-render where the component function runs again with the new value.
Rn React Hooks State ManagementDifficulty 1
A component has const [user, setUser] = useState({ name: 'Ada', age: 30 });. Calling setUser({ age: 31 }) is run to update just the age. What happens to name?
  • aReact automatically merges the new object with the old one, so name is preserved.
  • bThe state becomes { age: 31 }name is lost, because useState replaces.
  • cReact throws a runtime error because the object is incomplete.
  • dname stays 'Ada' but becomes read-only for the rest of the component's life.
Explanation:Unlike class component this.setState, the useState setter replaces the whole value. To update one field you must spread the previous state: setUser(prev => ({ ...prev, age: 31 })).
Rn React Hooks State ManagementDifficulty 1
What does useEffect(() => { fetchData(); }, []) (empty dependency array) do?
  • aRuns fetchData before every render, including the first.
  • bRuns fetchData once, right after the component mounts.
  • cNever runs fetchData because the array is empty.
  • dRuns fetchData once per second automatically.
Explanation:An empty dependency array means the effect has no reactive dependencies, so React only runs it once after the initial mount, and never again on subsequent re-renders (unless the component unmounts and remounts).
Rn React Hooks State ManagementDifficulty 2
useEffect(() => { console.log('render'); }); is written with no second argument at all (no dependency array). When does it run?
  • aOnly once, on mount, exactly like an empty array.
  • bOnly when the component is about to unmount.
  • cAfter every single render, including the first and every re-render.
  • dNever, because omitting the array is invalid and React ignores it silently.
Explanation:Omitting the dependency array entirely (not even passing []) tells React to run the effect after every render — mount and every subsequent re-render — with no memoization at all.
Rn React Hooks State ManagementDifficulty 2
useEffect(() => {
  const sub = eventEmitter.addListener('update', onUpdate);
  return () => sub.remove();
}, []);

When does the returned function () => sub.remove() run?
  • aRight before the component unmounts, or before the effect re-runs.
  • bImmediately, synchronously, right after addListener is called.
  • cOnly if the app crashes and React needs to recover.
  • dEvery time any sibling component re-renders.
Explanation:The function returned from an effect is its cleanup. React calls it right before running the effect again (not applicable here since deps are []) and, in all cases, right before the component unmounts — the standard place to remove listeners registered by the effect.
Rn React Hooks State ManagementDifficulty 2
function Timer({ label }) {
  useEffect(() => {
    const id = setInterval(() => {
      console.log(label);
    }, 1000);
    return () => clearInterval(id);
  }, []);
}

label changes over time via a prop update, but the console keeps logging the very first value it saw. Why?
  • aconsole.log caches its first argument forever across all calls.
  • bsetInterval in React Native ignores closures entirely.
  • cThis is a compiler error and the code would not actually run.
  • dThe effect's empty deps mean the closure over label is only created once.
Explanation:Because the effect only runs once ([]), the callback passed to setInterval closes over the label value from that first render only. Later renders create a new label variable, but the already-running interval keeps referencing the old one — a classic stale closure bug.

Test yourself against the 2400-question Mobile bank.

Start interview