react-navigation-mobx-helpers
React-Navigation bindings for MobX
Installation
npm install react-navigation-mobx-helpers --save
Usage
import React from 'react';import Provider inject observer from 'mobx-react';import StackNavigator from 'react-navigation';import NavigationStore from 'react-navigation-mobx-helpers'; const RootNavigator = ; const rootNavigation = ; Component { return <Provider => <App /> </Provider> ; } @@observerComponent { const rootNavigation = thisprops; return <RootNavigator = />; }
API
Action | Parameter | Description |
---|---|---|
createRef |
ref: React.Component |
Save an instance of navigation to store |
dispatch |
action: NavigationAction |
Send an action to router |
getParam |
paramName: string, fallback?: NavigationParams |
Get a specific param with fallback |
setParams |
newParams: NavigationParams |
Make changes to route's params |
navigate |
{ routeName: string, params?: NavigationParams, action?: NavigationAction, key?: string } OR routeName: string, params?: NavigationParams, action?: NavigationAction |
Go to another screen, figures out the action it needs to take to do it |
push |
routeName: string, params?: NavigationParams, action?: NavigationAction |
Navigate forward to new route in stack |
replace |
routeName: string, params?: NavigationParams, action?: NavigationAction |
Replace the current route with a new one |
goBack |
routeKey?: string \| null |
Close active screen and move back in the stack |
pop |
n?: number, params?: { immediate?: boolean } |
Go back in the stack |
popToTop |
params?: { immediate?: boolean } |
Go to the top of the stack |