Skip to content

Commit a065c5c

Browse files
authored
fix: added ctx to reducer
1 parent 70fab95 commit a065c5c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/index.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,20 @@ export const reducer = handleActions({
3333
// hook
3434
export const hookRedux = ({ dispatch, server }) => ({
3535
start: ({ path, location, ctx }) => {
36-
dispatch(start({ path, location, isTransition: true, ctx.toObject() }));
36+
const plainCtx = ctx.toObject();
37+
dispatch(start({ path, location, isTransition: true, ctx: plainCtx }));
3738
},
38-
resolve: ({ route, status, params, redirect }) => {
39-
server && dispatch(end({ route, status, params, redirect, isTransition: false, ctx.toObject() }));
39+
resolve: ({ route, status, params, redirect, ctx }) => {
40+
const plainCtx = ctx.toObject();
41+
server && dispatch(end({ route, status, params, redirect, isTransition: false, ctx: plainCtx }));
4042
},
41-
render: ({ route, status, params, redirect }) => {
42-
dispatch(end({ route, status, params, redirect, isTransition: false, ctx.toObject() }));
43+
render: ({ route, status, params, redirect, ctx }) => {
44+
const plainCtx = ctx.toObject();
45+
dispatch(end({ route, status, params, redirect, isTransition: false, ctx: plainCtx }));
4346
},
44-
error: ({ error: err }) => {
45-
dispatch(error({ err, isTransition: false, ctx.toObject() }));
47+
error: ({ error: err, ctx }) => {
48+
const plainCtx = ctx.toObject();
49+
dispatch(error({ err, isTransition: false, ctx: plainCtx }));
4650
},
4751
cancel: () => {
4852
console.warn('router cancel transition');

0 commit comments

Comments
 (0)