mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-05-11 23:58:31 +08:00
refactor: remove parent to child navigator communication
This commit is contained in:
@@ -205,37 +205,6 @@ const StackRouter: Router<CommonAction | Action> = {
|
||||
}
|
||||
},
|
||||
|
||||
getStateForChildUpdate(state, { update, focus }) {
|
||||
const index = state.routes.findIndex(r =>
|
||||
r.state ? r.state.key === update.key : false
|
||||
);
|
||||
|
||||
if (index === -1) {
|
||||
return state;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
index: focus ? index : state.index,
|
||||
routes: focus
|
||||
? [
|
||||
...state.routes.slice(0, index),
|
||||
{ ...state.routes[index], state: update },
|
||||
]
|
||||
: state.routes.map((route, i) =>
|
||||
i === index ? { ...route, state: update } : route
|
||||
),
|
||||
};
|
||||
},
|
||||
|
||||
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