Skip to content

Commit 9cb3c91

Browse files
committed
move endTransition to render
1 parent 8927049 commit 9cb3c91

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createAction, handleActions } from 'redux-actions-helpers';
22

33
// actions
44
export const startTransition = createAction('@@router/START_TRANSITION', payload => ({ payload }));
5+
export const resolved = createAction('@@router/RESOLVED', payload => ({ payload }));
56
export const endTransition = createAction('@@router/END_TRANSITION', payload => ({ payload }));
67

78
// reducer
@@ -12,7 +13,7 @@ const initialState = {
1213
status: null,
1314
params: null,
1415
redirect: null,
15-
16+
isTransition: false
1617
};
1718
export const reducer = handleActions({
1819
[startTransition]: (state, { payload }) => {
@@ -21,6 +22,12 @@ export const reducer = handleActions({
2122
...payload
2223
}
2324
},
25+
[resolved]: (state, { payload }) => {
26+
return {
27+
...state,
28+
...payload
29+
}
30+
},
2431
[endTransition]: (state, { payload }) => {
2532
return {
2633
...state,
@@ -32,9 +39,12 @@ export const reducer = handleActions({
3239
// hook
3340
export const hookRedux = ({ dispatch }) => ({
3441
start: ({ path, location }) => {
35-
dispatch(startTransition({ path, location }));
42+
dispatch(startTransition({ path, location, isTransition: true }));
3643
},
3744
resolve: ({ route, status, params, redirect }) => {
3845
dispatch(endTransition({ route, status, params, redirect }));
46+
},
47+
render: () => {
48+
dispatch(endTransition({ isTransition: false }));
3949
}
4050
});

0 commit comments

Comments
 (0)