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