-
Notifications
You must be signed in to change notification settings - Fork 392
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
Documentation: Confusion over Apollo/Redux implementation #282
Comments
in the same file where you initialise Redux, in the same file where you boot React, in most cases this is |
Excellent, thank you for the prompt response. So I'm imagining then that react-snap basically goes through all your source files and looks for |
It starts real server, serves your app from it, it uses real browser to crawl it. It doesn't know anything about file structure or technology. You can use anything and organise it whatever you want |
Sorry to be a huge noob, but I've been trying to get this to work with Apollo, and I imagine a lot of other people have been struggling as well. I've been using this guide as a vague reference, also using the redux example. https://www.apollographql.com/docs/react/features/server-side-rendering.html I've managed to come up with something like this so far, but I'm not 100% sure if it's correct. Thought I might put it out there for other people as well :)
Although I don't believe it works, getting this error when building: Will have to do some extensive playing around, I think. At the very least it works when running the app, it may be related to something else. |
If my words made you feel like that, I'm sorry I didn't mean it. You are doing fine. There are no stupid questions, there are people who can't answer some questions...
This is different error. It is reported somewhere else, I believe there is even fix somewhere in PRs Just inspect result HTML files, if they contain |
Oh wow, that is a really helpful piece of information. Thank you. Just a question: Is it the case that I need to run |
|
Thanks @stereobooster. I've got it all working, however I've come to the realisation that react-snap won't work for my project. Basically, I've noticed it will render the state of the application at a particular moment, but all the actual javascript functionality has been removed - so none of the buttons work to dynamically generate things. Ah well, trial and error - I may have a look at something like Razzle. But still, really good to know and a great library you've created - will definitely use it if I'm building something more static :) |
You just catched another bug. If you use CRA2, there is a bug #264. |
Oh, thank god - nice to know I'll give it another try. |
I implemented the fix. Holy Crap, I can't believe my application is available as a static site and I don't have to go through the pain of setting up SSR. You are a genius, this library is incredible. Thank you @stereobooster |
Just to make sure, you understand that if you use dynamic API when you do snapshots your static content can deviate from what your API returns, right? |
Yes, I understand that aspect. Which is fine because the dynamic aspect of the page isn't really specific to SEO, so it doesn't really matter what it shows in the snapshot. But I kind of see it as a positive thing anyway, because the way the app is written it will display different information in each snap per build, which I imagine is good for SEO as it demonstrates that the content is remaining up to date. |
@dottjt can you please share the code with which you got it working for Appollo? |
In the redux section it mentions this code:
However, I suppose the confusion is for me - where does this code actually go?
The text was updated successfully, but these errors were encountered: