Closed vianhanif closed 6 years ago
@vianhanif This is also a feature in this boilerplate. You can use a static fetchData
method on your component to pre-fetch on the server side. See https://github.com/combine/universal-react-redux#pre-fetching-data-for-server-side-rendering-ssr
Closing for now. Feel free to reopen if I've misinterpreted your question.
ooh hha, you're right... stupid me. sorry for the hassle. Thanks 😄
@calvinl what other objects available from fetchData other than the store object?
See here: https://github.com/combine/universal-react-redux/blob/master/server/renderer/handler.js#L116
fetchData is called with an object that includes: { store, route, match }
, where match
is the object returned by react-router
's matchPath
Similarly, this is a feature that Next.js has provided with getInitialProps function (if you might already know, it basically giving us the possibility to run redux actions to prefetch data from backend, so the component will already has data to render with). Has anyone tried it ? any help would be great because Next.js is the last thing I want to use for my work. Thanks~