mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-29 12:55:21 +08:00
Use redux constants and action creator functions (#120)
This commit is contained in:
committed by
Satyajit Sahoo
parent
b805978d9b
commit
2e6f7a015f
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user