Navigation
54 bites tagged Navigation — interview questions with model answers, and 60-second explainers.
Managing camera lifecycle in Vision Camera
Bind the isActive prop to screen focus via useIsFocused and to app state, so the camera stops when blurred or backgrounded. Camera resource lifecycle. leaving isActive always true or unmounting instead of toggling isActive.
Shared element transitions with Reanimated
Wrap both views in Animated.View with the same sharedTransitionTag, use a native-stack navigator so Reanimated interpolates between source and target. Cross-screen animated continuity.
Setting screen options statically versus dynamically
Options prop on Screen (can read route) versus navigation.setOptions inside the screen for state-driven changes. static versus dynamic screen options. trying to set state-based titles via the static options object only.
Accessing navigation outside a screen component
Use the useNavigation hook inside any component under NavigationContainer; for navigating outside React, use a navigationRef. getting navigation without the prop. prop-drilling navigation down manually through many layers.
Structuring an auth flow in React Navigation
Conditionally render an auth stack versus app stack from state, not navigate calls; store token; let state drive screens. navigator structuring around auth state. navigating between stacks manually instead of swapping them.
navigate vs push in a Stack Navigator
Navigate goes to an existing instance of the route if present, otherwise pushes; push always adds a new instance onto the stack. Use push to revisit the same screen with new params. stack navigation semantics.
Decoupled Cross-Module Navigation in Modular iOS
Depend on a shared abstraction, register concrete routers in a coordinator or registry, resolve at runtime. decoupling feature modules. importing module B directly or coupling features through a god object.
Push vs Modal Presentation in UIKit
Push adds to a nav stack with back, modal presents a self-contained interrupting flow. understanding of UIKit navigation models. treating them as interchangeable or ignoring the stack relationship.
Track location continuously in the background
Set desiredAccuracy, distanceFilter, activityType; enable the Location background mode and allowsBackgroundLocationUpdates; request Always authorization. Tuning Core Location for accuracy versus battery and enabling background updates.
Per-tab navigation stacks with StatefulShellRoute
StatefulShellRoute keeps a separate Navigator and preserved state per branch, with a shared shell scaffold. building independent per-tab stacks. rebuilding tab contents or losing scroll and stack on tab switch.
How would you architect the app root for onboarding vs authenticated flows?
Tests window root swapping and state-driven architecture. Use a coordinator to own the window, swap rootViewController between nav and tab controllers on auth changes, and crossfade. Red flag: onboarding modal over tabs or keeping both hierarchies alive.
Implement SwiftUI navigation between list and detail with product ID
Tests modern SwiftUI navigation and clean data flow. Great answer: NavigationStack with NavigationLink(value:) and navigationDestination(for:), plus a bound path for programmatic control.
Unwind Segues: Jump Back in the Stack
An unwind segue jumps from a deep screen to an earlier view controller without manual popping. Use it after multi-step flows to return to a root screen. If multiple screens share the same action, UIKit picks the nearest one and silently routes users wrong.
Map Data to Views Using navigationDestination
navigationDestination turns NavigationStack into a router: register a view per data type, then push raw values. It frees view models from creating views. Using it outside NavigationStack or mixing it with old NavigationLink destinations silently breaks…
How do you synchronize app state with GoRouter navigation?
Read auth state in top-level redirect; rebuild GoRouter via refreshListenable on changes; handle deep links in page builders. declarative routing and state-driven redirects.
Custom fade-and-scale transition with PageRouteBuilder and GoRoute
Tests bridging imperative transitions to declarative routers. Use PageRouteBuilder with FadeTransition and ScaleTransition, set globally in theme or per route via GoRoute pageBuilder with CustomTransitionPage. Red flag: omitting child rebuilds the page.
Implement a GoRouter path parameter route and access userId in a widget
This tests GoRouter declarative routing and GoRouterState. Define a GoRoute with path '/users/:userId', read state.params['userId'] in the builder, and handle null-safety. A red flag is parsing the URI manually or using ModalRoute.of instead of state.params.
Navigator.push vs Navigator.pushNamed in Flutter
Tests Flutter navigation patterns and scalability. A strong answer contrasts inline widget construction with centralized route tables, noting pushNamed centralizes routes but complicates type-safe data. Red flag: named routes are always better for large apps.
How do you pass data with Navigator.push and return data with Navigator.pop?
Tests imperative navigation and async result patterns. Strong answer: push via MaterialPageRoute with constructor args; await the Future from Navigator.push; pop with Navigator.pop(context, result). Red flag: using global state instead of the Future result.
Passing Arguments to Flutter Named Routes
Flutter named routes pass data through an arguments field instead of global variables. Use this when navigating to a route that needs an ID or configuration object. Arguments are untyped by default, so unsafe casts crash at runtime.
How do you navigate between feature modules without direct dependencies?
This tests architectural decoupling in multi-module Android apps. A great answer describes a shared navigation contract or deep-link router that lets features stay independent. Recommending direct Gradle dependencies between features is a major red flag.
How would you use a nested navigation graph for a login flow?
Tests modular navigation scoping. Strong answers group the three screens under a nested graph with its own start destination, noting encapsulation and reusability.
Describe the Android Activity lifecycle and callback order
Away calls onPause then onStop; back calls onRestart, onStart, onResume; onCreate only runs after destruction. Activity callback order during user navigation. Claiming onDestroy or onCreate run on every away-and-back.
Navigate between feature modules without direct dependencies?
Tests dependency inversion in modular apps. Answer by defining navigation interfaces in a shared module, implementing them in the :app module, and using DI to connect them. A red flag is suggesting direct module dependencies or using reflection for navigation.
Get Navigation bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.