You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
optional user-defined reducer for scenes, you may want to use it to intercept all actions and put your custom logic
createReducer
function
function that returns a reducer function for {initialState, scenes} param, you may wrap Reducer(param) with your custom reducer, check Flux usage section below
other props
all properties that will be passed to all your scenes
children
required (if no scenes property passed)
Scene root element
scenes
object
optional
scenes for Router created with Actions.create. This will allow to create all actions BEFORE React processing. If you don't need it you may pass Scene root element as children
getSceneStyle
function
optional
Optionally override the styles for NavigationCard's Animated.View rendering the scene.
backAndroidHandler
function
optional
Optionally override the handler for BackAndroid, return true to stay in the app or return false to exit the app. Default handler will pop a scene and exit the app at last when the back key is pressed on Android.
onBackAndroid
function
optional
Get called after back key is pressed and a scene is poped, won't affect the default behavior.
onExitApp
function
optional
Optionally override the default action after back key is pressed on root scene. Return true to stay, or return false to exit the app.
Scene:
Property
Type
Default
Description
key
string
required
Will be used to call screen transition, for example, Actions.name(params). Must be unique.
component
React.Component
semi-required
The Component to be displayed. Not required when defining a nested Scene, see example. If it is defined for 'container' scene, it will be used as custom container renderer
initial
bool
false
Set to true if this is the initial scene
type
string
ActionConst.PUSH or ActionConst.JUMP
Defines how the new screen is added to the navigator stack. One of ActionConst.PUSH, ActionConst.JUMP, ActionConst.REPLACE, ActionConst.RESET. If parent container is tabbar (tabs=true), ActionConst.JUMP will be automatically set.
clone
bool
Scenes marked with clone will be treated as templates and cloned into the current scene's parent when pushed. See example.
passProps
bool
false
Pass all own props (except style, key, name, component, tabs) to children. Note that passProps is also passed to children.
ActionConst:
We accept shorthand string literal when defining scene type or action params, like:
are just a bunch of constants represent real values of various actions/scene.type to avoid future changes.
you can treat it like redux action.
These can be used directly, for example, Actions.pop() will dispatch correspond action written in the source code, or, you can set those constants in scene type, when you do Actions.main(), it will dispatch action according to your scene type or the default one.
Not every ActionConst can be used the same way ( use as an action or whether it can be set in scene type or not)
that's why it's just a bunch of constants to mask the actual values.
Scene.type
Defines how the new screen is added to the navigator stack. One of push, modal, actionSheet, replace, switch, reset transitionToTop. Default is 'push'.
And every Scene.type string literal has a mapped constant in ActionConst, it is recommended to always use constant.
replace: tells navigator to replace current route with new route. actionSheet: shows Action Sheet popup, you must pass callback as callback function. modal: type inserts its 'component' into route stack after navigator component. It could be used for popup alerts as well for various needed processes before any navigator transitions (like login auth process). it could be dismissed by using Actions.dismiss(). switch: is used for tab screens. reset: is similar to replace except it unmounts the componets in the navigator stack. transitionToTop: will reset router stack ['route.name'] and with animation, if route has sceneConfig. eg <Route name="login" schema="modal" component={Login} type="transitionToTop" />
Animation
Property
Type
Default
Description
duration
number
optional. acts as a shortcut to writing an applyAnimation function with Animated.timing for a given duration (in ms).
direction
string
'horizontal'
direction of animation horizontal/vertical/leftToRight ('horizontal' will be right to left)
animation
string
animation options when transitioning: 'fade' currently only option
animationStyle
function
optional interpolation function for scene transitions: animationStyle={interpolationFunction}
applyAnimation
function
optional if provided overrides the default spring animation
Gestures
Property
Type
Default
Description
panHandlers
object
optional, provide null to disable swipe back gesture
getPanHandlers
function
optional
Optionally override the gesture handlers for scene
Optionally override the styles for NavigationCard's Animated.View rendering the scene. Receives first argument of NavigationSceneRendererProps and second argument of {hideNavBar,hideTabBar,isActive} (see Example app).
Tabs
Property
Type
Default
Description
tabs
bool
false
Defines 'TabBar' scene container, so child scenes will be displayed as 'tabs'. If no component is defined, built-in TabBar is used as renderer. All child scenes are wrapped into own navbar.
optional style override for the back title element
hideBackImage
boolean
false
no default back button image will be displayed
onBack
function
Actions.pop
actions for back button
Navigation Bar: Left button
Property
Type
Default
Description
leftTitle
string
optional string to display on the left if the previous route does not provide renderBackButton prop. renderBackButton > leftTitle > <previous route's title>
getLeftTitle
function
optional closure to display on the left if the previous route does not provide renderBackButton prop. renderBackButton > getLeftTitle > <previous route's title>
renderLeftButton
function
optional closure to render the left title / buttons element
onLeft
function
function will be called when left navBar button is pressed