Skip to content
This repository has been archived by the owner on Jan 26, 2020. It is now read-only.

how to pass props directly to each page component (and is it worth the hassle?) #6

Closed
alidcast opened this issue Jul 2, 2018 · 1 comment

Comments

@alidcast
Copy link
Owner

alidcast commented Jul 2, 2018

Right now any data returned from getInitialProps will be passed to the App.js component. That component can then delegate the data to each page component.

Obviously, this isn't ideal as each getInitialProps should operate in a black box.

Some ideas for handling this correctly:

  • As we walk the component tree, we can recreate it and pass each component the correct data (honestly not even sure if this could work?)
  • We can do what loadable-components does and pass data from server to window object and the render component with appropriate data (this seems like the way to go)

However, I don't know to what extent this is worth the hassle. If you're using Apollo, you don't really need to fetch data from getInitialProps (right??). So it's only useful for plugin hocs (e.g. Apollo, Redux, etc) to server render their own data (which would be passed to App.js anyway) and to handle route middleware in the server (which doesn't return any data).

So going to leave it as it is for now but posting my thoughts here for reference

@alidcast alidcast changed the title how to pass props directly to each page component how to pass props directly to each page component (and is it worth the hassle?) Jul 2, 2018
@alidcast
Copy link
Owner Author

alidcast commented Jul 3, 2018

see #7 too, I decided it's not :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant