Skip to content

Commit

Permalink
Improve composability of useSsrGlobalState
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Nov 12, 2022
1 parent cccdf8c commit 6708fbf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/useSsrGlobalState.tsx
Expand Up @@ -224,12 +224,15 @@ export function createUseSsrGlobalState<T, Name extends string>(

}

const super_getInitialProps =
App.getInitialProps?.bind(App) ??
DefaultApp.getInitialProps.bind(DefaultApp);

Object.keys(App)
.forEach(staticMethod => (AppWithXyz as any)[staticMethod] = (App as any)[staticMethod]);

AppWithXyz.getInitialProps = async (appContext: AppContext): Promise<AppWithXyzProps> => ({
"initialProps": App.getInitialProps ? await App.getInitialProps(appContext as any) : {},
"initialProps": await super_getInitialProps(appContext),
"xyzServerInfos": await (async () => {

if (!isServer) {
Expand Down

0 comments on commit 6708fbf

Please sign in to comment.