Skip to content

Commit

Permalink
refactor: Swap middleware execution order (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaachinman authored Jul 29, 2020
1 parent 54f8195 commit 01069e3
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/hocs/app-with-translation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,6 @@ export const appWithTranslation = function (WrappedComponent) {

await initPromise

let wrappedComponentProps: WrappedComponentProps = { pageProps: {} }
if (WrappedComponent.getInitialProps) {
wrappedComponentProps = await WrappedComponent.getInitialProps(ctx)
}
if (typeof wrappedComponentProps.pageProps === 'undefined') {
consoleMessage(
'error',
'If you have a getInitialProps method in your custom _app.js file, you must explicitly return pageProps. For more information, see: https://github.com/zeit/next.js#custom-app',
)
}

/*
Initiate vars to return
*/
Expand All @@ -100,6 +89,18 @@ export const appWithTranslation = function (WrappedComponent) {
}
}

/* Call getInitialProps on our wrapped _app */
let wrappedComponentProps: WrappedComponentProps = { pageProps: {} }
if (WrappedComponent.getInitialProps) {
wrappedComponentProps = await WrappedComponent.getInitialProps(ctx)
}
if (typeof wrappedComponentProps.pageProps === 'undefined') {
consoleMessage(
'error',
'If you have a getInitialProps method in your custom _app.js file, you must explicitly return pageProps. For more information, see: https://github.com/zeit/next.js#custom-app',
)
}

/*
Step 1: Determine initial language
*/
Expand Down

0 comments on commit 01069e3

Please sign in to comment.