@@ -30,32 +30,18 @@ export const reducer = handleActions({
3030} , { initialState } ) ;
3131
3232// hook
33- export const firstHookRedux = ( { dispatch, server } ) => {
34- const hook = { } ;
35- if ( server !== true ) {
36- hook [ 'render' ] = ( { route, status, params, redirect } ) => {
37- dispatch ( end ( { route, status, params, redirect, isTransition : false } ) ) ;
38- }
39- }
40- return hook ;
41- } ;
42- export const lastHookRedux = ( { dispatch, server } ) => {
43- const hook = {
44- start : ( { path, location } ) => {
45- dispatch ( start ( { path, location, isTransition : true } ) ) ;
46- } ,
47- error : ( { error : err } ) => {
48- dispatch ( error ( { err, isTransition : false } ) ) ;
49- } ,
50- cancel : ( ) => {
51- console . warn ( 'router cancel transition' ) ;
52- // dispatch(cancel());
53- }
54- } ;
55- if ( server === true ) {
56- hook [ 'resolve' ] = ( { route, status, params, redirect } ) => {
57- dispatch ( end ( { route, status, params, redirect, isTransition : false } ) ) ;
58- }
33+ export const hookRedux = ( { dispatch, server } ) => ( {
34+ start : ( { path, location } ) => {
35+ dispatch ( start ( { path, location, isTransition : true } ) ) ;
36+ } ,
37+ resolve : ( { route, status, params, redirect } ) => {
38+ dispatch ( end ( { route, status, params, redirect, isTransition : false } ) ) ;
39+ } ,
40+ error : ( { error : err } ) => {
41+ dispatch ( error ( { err, isTransition : false } ) ) ;
42+ } ,
43+ cancel : ( ) => {
44+ console . warn ( 'router cancel transition' ) ;
45+ // dispatch(cancel());
5946 }
60- return hook ;
61- } ;
47+ } ) ;
0 commit comments