React NativeScript

React NativeScript

  • Docs

›ELEMENTS: COMPONENTS

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

Page

<page> is a UI component that represents an application screen. NativeScript apps typically consist of one or more <page> that wrap content such as an <actionBar> and other UI widgets.

See also:

  • Official top-level documentation
  • Detailed API specification

Basic example

import * as React from "react";

<page>
  <actionBar title="My App" />
  <gridLayout>
    <label>My Content</label>
  </gridLayout>
</page>

The special case of the ActionBar child

It doesn't matter whether the <actionBar> is a first child, last child, or middle child of <page>. React NativeScript will automatically detect it using an child instanceof Page check, and set it as the ActionBar for the Page. Note: You can skip this check by explicitly setting <actionBar nodeRole="actionBar">, but it's not a major performance concern.

Any non-ActionBar child will be handled as the content view. Page only supports a single child, so if you want to insert multiple children on the Page (which is normally the case!), you should use a LayoutBase such as GridLayout to enscapsulate them.

Out of interest: You'd expect to be able to set ActionBar as the content view by specifying <actionBar nodeRole="content">, but it's not supported in NativeScript Core, so React NativeScript doesn't support it either!

Props

NameTypeDescription
actionBarHiddenbooleanShows or hides the <actionBar> for the page.
Default value: false.
backgroundSpanUnderStatusBarbooleanGets or sets whether the background of the page spans under the status bar.
Default value: false.
androidStatusBarBackgroundColor(Android-only) Gets or sets the color of the status bar on Android devices.
enableSwipeBackNavigationboolean(iOS-only) Gets or sets whether the page can be swiped back on iOS.
Default value: true.
statusBarStylestringGets or sets the style of the status bar.
Valid values:
light,
dark.
onNavigatedFrom(args:NavigatedData) => voidEmitted after the app has navigated away from the current page.
onNavigatedTo(args:NavigatedData) => voidEmitted after the app has navigated to the current page.
onNavigatingFrom(args:NavigatedData) => voidEmitted before the app has navigated away from the current page.
onNavigatingTo(args:NavigatedData) => voidEmitted before the app has navigated to the current page.

Native component

AndroidiOS
org.nativescript.widgets.GridLayoutUIViewController
Last updated by Jamie Birch
← NavigationButtonPlaceholder →
  • Props
  • Native component
React NativeScript
Docs
Getting StartedUI Components Reference
Community
Stack OverflowChat on Slack in #reactTwitter
More
GitHub – React NativeScriptGitHub – Docs Site
Copyright © 2021 Jamie Birch