Skip to content

Commit 70fab95

Browse files
authored
added ctx to reducer
1 parent 4bb32c4 commit 70fab95

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const initialState = {
1515
params: {},
1616
redirect: null,
1717
error: null,
18-
isTransition: false
18+
isTransition: false,
19+
ctx: {}
1920
};
2021
export const reducer = handleActions({
2122
[start + end + error]: (state, { payload }) => {
@@ -31,17 +32,17 @@ export const reducer = handleActions({
3132

3233
// hook
3334
export const hookRedux = ({ dispatch, server }) => ({
34-
start: ({ path, location }) => {
35-
dispatch(start({ path, location, isTransition: true }));
35+
start: ({ path, location, ctx }) => {
36+
dispatch(start({ path, location, isTransition: true, ctx.toObject() }));
3637
},
3738
resolve: ({ route, status, params, redirect }) => {
38-
server && dispatch(end({ route, status, params, redirect, isTransition: false }));
39+
server && dispatch(end({ route, status, params, redirect, isTransition: false, ctx.toObject() }));
3940
},
4041
render: ({ route, status, params, redirect }) => {
41-
dispatch(end({ route, status, params, redirect, isTransition: false }));
42+
dispatch(end({ route, status, params, redirect, isTransition: false, ctx.toObject() }));
4243
},
4344
error: ({ error: err }) => {
44-
dispatch(error({ err, isTransition: false }));
45+
dispatch(error({ err, isTransition: false, ctx.toObject() }));
4546
},
4647
cancel: () => {
4748
console.warn('router cancel transition');

0 commit comments

Comments
 (0)