-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[1.0] Question - How to gatsby+redux ssr successfully? #1079
Comments
Silly question but how would you SSR if this is a static site? |
@akadop Not a silly question at all! I suppose the terminology is confusing, and frankly I'm not even sure I'm using it correctly. I'm referring to the build-html phase that gets executed by |
@akadop I was thinking about that the other day — we might not want to use |
@scottyeck it looks actually right except you need to put the API implementation in We really need to get API validation in pronto. It's super easy to get tripped up by silly stuff like this and it's very easy to automatically validate. I might do something really simple today actually. |
@KyleAMathews Oops - thanks for looking. I probably should have picked up on that when I looked through the source. Thanks for your help! Obviously moving the implementation into |
An example site would be fantastic!
…On Thu, Jun 1, 2017 at 8:32 AM Scotty Eckenthal ***@***.***> wrote:
@KyleAMathews <https://github.com/kyleamathews> Oops - thanks for
looking. I probably should have picked up on that when I looked through the
source. Thanks for your help!
Obviously moving the implementation into gatsby-ssr.js got past that
error. Working through a few more issues but happy to PR the example if
you'd like.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1079 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEVh-9PQyo4L-Y5vlZH75AwGe6aig8tks5r_tmOgaJpZM4NtBvv>
.
|
No problem at all - setting them up is really helpful as a POC before I move into development in our app. Also, it lays the foundation for a plugin later on. |
Hi, I followed the PR's example but I still get the error on build. |
@oltodo bit late but did you figure it out? If you're using any For my project this error occurred after adding Anyway, to get the example working with
Maybe this is obvious, but being new to Gatsby this caused a couple hours of debugging ... @KyleAMathews maybe a note can be added either to the Redux example or the |
Oh right — this has been a TODO for a while so would love it if you want to tackle it! Basically when we load plugins, we should detect if there's multiple plugins that implement certain APIs (like |
Will try to get to it in the next couple weeks, no need to be sorry, really liking Gatsby so far! |
Your solution works fine for me @aboutevan. Thanks for your research! Fortunately for us, the styled-components plugin's code is very simply and is not hard to duplicate. |
Cl |
If anyone looking complete example that's using Redux and Redux-Devtools together with CSS-in-JS; |
If you use
replaceRouterComponent
to wrap your<Router>
in with a<Provider>
- necessary with use ofreact-router-redux
, since your<Router>
should be passed astore
instance - then because the<Router>
gets replaced with a<StaticRouter>
in thestatic-entry
, this<Provider>
isn't available at ssr-time. As a result, if the ssr-process attempts to render a connected-component, an error of the following type is thrown:I've attempted to resolve this (thus far unsuccessfully) using the
replaceServerBodyRender
hook ingatsby-node.js
- see example here: https://github.com/fabrictech/gatsby/tree/redux-example/examples/redux.I'm hoping that a new
apiRunner
hook needn't be added to achieve this, but if so, I'm happy to work on it and/or consult. Any suggestions or guidance would be awesome.The text was updated successfully, but these errors were encountered: