Custom navigation with Navigator component in React-Native
Data Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.
Introduction
React Navigation is the standard library for navigation in React Native. It provides stack, tab, drawer, and bottom tab navigators out of the box. For custom navigation flows, you can create a custom navigator using createNavigatorFactory and useNavigationBuilder, or customize built-in navigators with screen options, custom tab bars, and custom headers. The legacy Navigator component from early React Native is deprecated — use React Navigation v6+ instead.
Setting Up React Navigation
Basic Stack Navigation
Custom Tab Bar
Custom Header
Nested Navigators
Conditional Navigation (Auth Flow)
Common Pitfalls
- Using the deprecated Navigator component: The original
Navigatorfrom React Native core was removed years ago. Use@react-navigation/native(v6+) which is actively maintained and provides better performance, TypeScript support, and customization options. - Wrapping NavigationContainer multiple times:
NavigationContainermust be rendered exactly once at the root of your app. Nesting it inside anotherNavigationContainercauses navigation state conflicts and crashes. Use nested navigators (Stack.NavigatorinsideTab.Navigator) without extra containers. - Not passing navigation prop to custom components: Custom tab bars and headers receive
navigation,state, anddescriptorsas props from the navigator. Forgetting to destructure and use these props causesnavigation.navigate is not a functionerrors. - Hiding the header without headerShown: Setting
headerMode: 'none'is deprecated. UsescreenOptions={{ headerShown: false }}on the navigator oroptions={{ headerShown: false }}on individual screens to hide the header. - Deep linking without linking configuration: Custom navigation flows that support deep links (URLs opening specific screens) require a
linkingprop onNavigationContainer. Without it, deep links are ignored silently. Define alinkingconfig with path mappings for each screen.
Summary
- Use
@react-navigation/nativev6+ for all React Native navigation (the legacyNavigatoris deprecated) - Customize tab bars with the
tabBarprop onTab.Navigator - Customize headers with the
headerscreen option onStack.Navigator - Nest navigators (stack inside tabs, tabs inside drawer) for complex navigation flows
- Use conditional rendering inside
NavigationContainerfor auth flows - Install
react-native-screensandreact-native-safe-area-contextfor proper native behavior
Related reading
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.