refactor: remove parent to child navigator communication

This commit is contained in:
satyajit.happy
2019-07-12 22:41:48 +02:00
parent 2e08df9a1d
commit 6686e0ab58
6 changed files with 47 additions and 198 deletions

View File

@@ -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 } };