async function getContextIndependentWrappedInitialProps (PageComponent, ctx) { const inAppContext = Boolean(ctx.ctx) let pageProps = {} if (PageComponent.getInitialProps) { pageProps = await PageComponent.getInitialProps(ctx) } else if (inAppContext) { pageProps = await App.getInitialProps(ctx) } return pageProps }
// use getInitialProps to create a store static async getInitialProps(appContext) { const mobxStore = initStore(); appContext.ctx.mobxStore = mobxStore; let appProps = await App.getInitialProps(appContext); return { ...appProps, initialMobxState: mobxStore } }
async function getContextIndependentWrappedInitialProps (PageComponent, ctx) { const inAppContext = Boolean(ctx.ctx) let pageProps = {} if (PageComponent.getInitialProps) { pageProps = await PageComponent.getInitialProps(ctx) } else if (inAppContext) { pageProps = await App.getInitialProps(ctx) } return pageProps }