-
Notifications
You must be signed in to change notification settings - Fork 30k
Closed
Description
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 - getInitialProps
- Page - getInitialProps dispatches an action
- store state is now
{ page: 'ok', doc: 'init' } - MyDocument - getInitialProps
- Page - renders with `{ page: 'ok', doc: 'init' } that's the problem, render happens before _document's getInitialProps call
- MyDocument - getInitialProps dispatches an action
- store is now { page: 'ok', doc: 'ok' }
- MyDocument - renders with { page: 'ok', doc: 'ok' }
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.
Metadata
Metadata
Assignees
Labels
No labels