Skip to content

Commit 533ce5d

Browse files
committed
added error action
1 parent f21a04d commit 533ce5d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createAction, handleActions } from 'redux-actions-helpers';
44
export const startTransition = createAction('@@router/START_TRANSITION', payload => ({ payload }));
55
export const resolved = createAction('@@router/RESOLVED', payload => ({ payload }));
66
export const endTransition = createAction('@@router/END_TRANSITION', payload => ({ payload }));
7+
export const error = createAction('@@router/ERROR', payload => ({ payload }));
78

89
// reducer
910
const initialState = {
@@ -13,6 +14,7 @@ const initialState = {
1314
status: null,
1415
params: null,
1516
redirect: null,
17+
error: null,
1618
isTransition: false
1719
};
1820
export const reducer = handleActions({
@@ -33,6 +35,12 @@ export const reducer = handleActions({
3335
...state,
3436
...payload
3537
}
38+
},
39+
[error]: (state, { payload }) => {
40+
return {
41+
...state,
42+
...payload
43+
}
3644
}
3745
}, { initialState });
3846

@@ -46,5 +54,8 @@ export const hookRedux = ({ dispatch }) => ({
4654
},
4755
render: () => {
4856
dispatch(endTransition({ isTransition: false }));
57+
},
58+
error: ({ error }) => {
59+
dispatch(error({ error, isTransition: false }));
4960
}
5061
});

0 commit comments

Comments
 (0)