Use redux constants and action creator functions (#120)

This commit is contained in:
Jeff Carbonella
2017-02-01 16:27:51 -05:00
committed by Satyajit Sahoo
parent b805978d9b
commit 2e6f7a015f
25 changed files with 317 additions and 164 deletions

View File

@@ -78,7 +78,7 @@ const MyAppRouter = {
getStateForAction(action, state) {
if (
state &&
action.type === 'Back' &&
action.type === NavigationActions.BACK &&
state.routes[state.index].params.isEditing
) {
// Returning null from getStateForAction means that the action
@@ -97,6 +97,8 @@ Perhaps your app has a unique URI which the built-in routers cannot handle. You
```js
import { NavigationActions } from 'react-navigation'
const MyApp = StackNavigator({
Home: { screen: HomeScreen },
Profile: { screen: ProfileScreen },
@@ -111,17 +113,15 @@ MyApp.router = {
params.magic === 'yes'
) {
// returns a profile navigate action for /my/custom/path?magic=yes
return {
type: 'Navigate',
return NavigationActions.navigate({
routeName: 'Profile',
action: {
action: NavigationActions.navigate({
// This child action will get passed to the child router
// ProfileScreen.router.getStateForAction to get the child
// navigation state.
type: 'Navigate',
routeName: 'Friends',
},
};
}),
});
return null;
}
return MyApp.router.getStateForAction(action, state);