how to pass props directly to each page component (and is it worth the hassle?) · Issue #6 · alidcast/rogue.js · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
8000
{{ message }}
This repository was archived by the owner on Jan 26, 2020. It is now read-only.
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
The text was updated successfully, but these errors were encountered:
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
Uh oh!
There was an error while loading. Please reload this page.
Right now any data returned from
getInitialProps
will be passed to theApp.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:
loadable-components
does and pass data from server towindow
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 pluginhocs
(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
The text was updated successfully, but these errors were encountered: