@@ -13,24 +13,44 @@ function rootReducer(state = initialState, action) {
1313 return state ;
1414 }
1515}
16+ const getIsServer = ( ) => typeof window == "undefined" ;
1617
17- const initializeStore = ( preloadedState = { } ) =>
18- createStore ( rootReducer , preloadedState ) ;
18+ const initializeStore = ( preloadedState = { } ) => createStore ( rootReducer ) ;
1919
2020function wrapper ( Component ) {
21- // function WithRedux(appProps) {
22- // const store = useRef(initializeStore());
23- // return (
24- // );
25- // }
21+ const displayName = `withRedux(${
22+ Component . displayName || Component . name || "Component"
23+ } )`;
24+
25+ const hasInitialProps = "getInitialProps" in Component ;
26+
27+ console . log ( { displayName, hasInitialProps } ) ;
2628
2729 class WithRedux extends App {
2830 constructor ( props ) {
2931 super ( props ) ;
3032 this . reduxStore = initializeStore ( ) ;
3133 }
3234
35+ static getInitialProps ( ctx ) {
36+ console . log ( ctx ) ;
37+
38+ return { } ;
39+ }
40+
3341 render ( ) {
42+ console . log ( this . props ) ;
43+
44+ const { initialState, initialProps, ...props } = this . props ;
45+
46+ console . log ( { initialProps, initialState } ) ;
47+
48+ let finalProps = { } ;
49+
50+ finalProps . pageProps = {
51+ initialState : this . reduxStore . getState ( ) ,
52+ } ;
53+
3454 return (
3555 < Provider store = { this . reduxStore } >
3656 < Component { ...this . props } /> ;
0 commit comments