mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-11 22:33:32 +08:00
feat: add target argument to setParams (#18)
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
CommonAction,
|
||||
ParamListBase,
|
||||
Router,
|
||||
BaseRouter,
|
||||
createNavigator,
|
||||
} from '../src/index';
|
||||
|
||||
@@ -28,9 +29,8 @@ type Action =
|
||||
| { type: 'POP_TO_TOP' };
|
||||
|
||||
export type StackNavigationProp<
|
||||
ParamList extends ParamListBase,
|
||||
RouteName extends keyof ParamList = string
|
||||
> = NavigationProp<ParamList, RouteName> & {
|
||||
ParamList extends ParamListBase
|
||||
> = NavigationProp<ParamList> & {
|
||||
/**
|
||||
* Push a new screen onto the stack.
|
||||
*
|
||||
@@ -55,6 +55,7 @@ export type StackNavigationProp<
|
||||
};
|
||||
|
||||
const StackRouter: Router<CommonAction | Action> = {
|
||||
...BaseRouter,
|
||||
getInitialState({
|
||||
routeNames,
|
||||
initialRouteName = routeNames[0],
|
||||
@@ -88,14 +89,6 @@ const StackRouter: Router<CommonAction | Action> = {
|
||||
return state;
|
||||
},
|
||||
|
||||
getStateForRouteNamesChange(state, { routeNames }) {
|
||||
return {
|
||||
...state,
|
||||
routeNames,
|
||||
routes: state.routes.filter(route => routeNames.includes(route.name)),
|
||||
};
|
||||
},
|
||||
|
||||
getStateForRouteFocus(state, key) {
|
||||
const index = state.routes.findIndex(r => r.key === key);
|
||||
|
||||
@@ -246,18 +239,10 @@ const StackRouter: Router<CommonAction | Action> = {
|
||||
}
|
||||
|
||||
default:
|
||||
return null;
|
||||
return BaseRouter.getStateForAction(state, action);
|
||||
}
|
||||
},
|
||||
|
||||
shouldActionPropagateToChildren(action) {
|
||||
return action.type === 'NAVIGATE';
|
||||
},
|
||||
|
||||
shouldActionChangeFocus(action) {
|
||||
return action.type === 'NAVIGATE';
|
||||
},
|
||||
|
||||
actionCreators: {
|
||||
push(name: string, params?: object) {
|
||||
return { type: 'PUSH', payload: { name, params } };
|
||||
|
||||
Reference in New Issue
Block a user