React NativeScript

React NativeScript

  • Docs

›CORE CONCEPTS

INTRODUCTION

  • Introduction

GETTING STARTED

  • Quick Start
  • Environment Setup
  • Using React Devtools

CORE CONCEPTS

  • Native Access
  • Navigation
  • Node Roles
  • Modals
  • Plugins
  • Styling

SAMPLES

  • Apps

ELEMENTS: LAYOUT

  • AbsoluteLayout
  • DockLayout
  • FlexboxLayout
  • GridLayout
  • StackLayout
  • WrapLayout

ELEMENTS: COMPONENTS

  • ActivityIndicator
  • ActionBar
  • ActionItem
  • Button
  • DatePicker
  • Frame
  • HtmlView
  • Image
  • Label
  • ListView
  • ListPicker
  • NavigationButton
  • Page
  • Placeholder
  • Progress
  • ScrollView
  • SearchBar
  • SegmentedBar
  • Slider
  • Switch
  • TabView
  • TabViewItem
  • TextField
  • TextView
  • TimePicker
  • WebView

LICENCES

  • Licences
Edit

Navigation

Introduction

To understand the full range of options for navigation in React NativeScript, we must first explore the options in NativeScript Core (for which React NativeScript acts as a React wrapper).

NativeScript Core navigation methods

NativeScript Core provides two main methods of navigation, summarised in their Navigation docs:

  • Stack-based navigation, via the Frame and Page components.
  • Tab-based navigation, via the deprecated TabView component, or, as of NativeScript 6, the newer Tabs or BottomNavigation components.

Nested navigation is also possible.

These navigation methods are fully native, i.e. the components involved are all wrappers around iOS/Android navigation solutions. Thus, you can expect excellent performance and a robust appearance.

React NativeScript navigation methods

DON'T use the NativeScript navigators directly

React NativeScript wraps all of the aforementioned components as React components, but it's fiddly to use them directly as all the navigation actions are non-declarative, meaning they don't map well to React and you have to do a lot of ref-handling. Without special care, you may find the navigator model going out of sync with your React state (e.g. due to neglecting to update the history stack upon user interaction).

Thus, I strongly recommend to not use <frame>, <page>, <tabView>, <tabs>, or <bottomNavigation> directly. It's a good way to lose your weekend chasing bugs.

DO use React NativeScript Navigation

Instead, I've implemented React Navigation v5 library for React NativeScript, which uses those navigation components under-the-hood. I've unimaginatively named it react-nativescript-navigation.

It has all the same APIs as React Navigation, and implements both a TabNavigator and a StackNavigator (SwitchNavigators are no longer necessary as of React Navigation v5).

Getting started
  • Read the README on the react-nativescript-navigation repo for basic usage details.
  • Refer to the React Navigation v5 docs for full detail on how to navigate.
Last updated by Jamie Birch
← Native AccessNode Roles →
  • Introduction
    • NativeScript Core navigation methods
    • React NativeScript navigation methods
React NativeScript
Docs
Getting StartedUI Components Reference
Community
Stack OverflowChat on Slack in #reactTwitter
More
GitHub – React NativeScriptGitHub – Docs Site
Copyright © 2021 Jamie Birch