-
Notifications
You must be signed in to change notification settings - Fork 27.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improper sequence of getInitialProps #1267
Comments
|
Exactly, try using an HoC instead of overriding the |
But that's what is recommended in readme ;) https://github.com/zeit/next.js#custom-document How HoC will help to fix the sequence? I understand that document is only needed on the backend but still, consistent execution flow is important, even if it's one-time thing... |
I'd say one of the advantages is that with redux what you want to pass from server to client is the initial store data post server-side rendering. I'm not saying overriding If you add an HoC into your pages then you go with the pages flow and don't worry about the data flow on the |
All true, of course it can be done via function composition only at page level inside |
Closing this since we already have a solution. Custom Document must use for changing the initial markup code. It should not used for anything related to your app. |
I have Redux and async actions in
getInitialProps
, but it will also produce same results w/o redux too.If
getInitialProps
function is used for both page and custom_document.js
, then the sequence is:{ page: 'ok', doc: 'init' }
So it seems, that
MyDocument.getInitialProps
is executed on page render, but I think, that such custom lifecycle methods should be called in sequence, before render, let's say, Page then Doc, so that on render everything is consistent.Master branch of https://github.com/kirill-konshin/next-redux-wrapper contains the example.
The text was updated successfully, but these errors were encountered: