-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrouter-native.js
39 lines (33 loc) · 907 Bytes
/
router-native.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {
Actions
} from 'react-native-router-flux';
export function go(pageId, params) {
return {
type: "GO",
pageId,
...params
};
}
export function getNavReducer() {
return function navReducer(store, state, action) {
if (action.type != "GO") return state;
console.log("Navigating...");
console.log(action);
if (Actions[action.pageId]) {
let params = {
...action
};
delete params.key;
delete params.pageId;
delete params.type;
console.log("found action");
console.log(params);
Actions[action.pageId](params);
return {...state, routeData: {...state.routeData, ...action}};
}
else {
console.error(`route ${action.pageId} is not mapped`);
}
return state;
};
}