Skip to the page

Navigation and deep linking · mid

Navigation actions, params, double taps and back handling

In React Navigation 7, navigate updates the current screen or pushes a new one (it no longer jumps back to an earlier screen), push always adds, popTo goes back to an earlier screen, and you stop double pushes, lost changes and wrong back behaviour with getId, in-flight locks and usePreventRemove.

The notes

What you must know

  • v7 navigate in a stack: if you are already on that screen, it updates params; otherwise it pushes; if getId matches a screen already in the stack, that screen comes to the front. To go back to an earlier screen use popTo, or navigate(name, params, { pop: true }).
  • push always adds; replace swaps the current screen; reset replaces the whole state; popTo(name) goes back to it (or replaces the current screen if it is not in the stack); preload renders a screen ahead of time.
  • navigate no longer reaches screens inside nested child navigators by name; use the nested form navigate("Tabs", { screen: "Orders", params }).
  • setParams merges params; replaceParams replaces them. Keep params small and serialisable (ids, not whole objects).
  • Double taps: the handler can run twice before the transition starts. Use navigate (it does not push a duplicate of the focused route), getId, an in-flight lock on the button, and server idempotency keys for payments.
  • usePreventRemove covers the header back button, Android back and the iOS swipe on native stack; BackHandler covers custom Android cases. Predictive back (Android 16) needs back interception declared ahead of time.
  • unmountOnBlur became popToTopOnBlur (tabs and drawer); <Link screen params> replaced <Link to>.

The red pen

Common traps: mistake → fix

  • Mistake: "navigate goes back to an existing screen"

    Fix: that was v6; in v7 use popTo.

  • Mistake: "Debounce the button and we are done"

    Fix: also lock the async work and make the server idempotent.

  • Mistake: "Pass the whole order object as a param"

    Fix: pass an id; big params break deep links and state persistence.

Easy to hard

Questions interviewers ask, easy to hard

  1. navigate vs push vs replace vs reset vs popTo: what does each do?
  2. What changed from v6 to v7 that broke code?
  3. A user taps Pay twice and two payment screens open. Fix it for the whole app.
  4. Handle the Android back button on a checkout screen with unsaved changes.

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview