-
Notifications
You must be signed in to change notification settings - Fork 52
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
Fix HistoryLocation in React v0.13 Example #67
Conversation
@ostrgard This seems to be a bug with React Router v0.13, whereas it works fine in React Router v0.14. The crazy part is, Thanks for putting together this demo! What I'm afraid of is there being an issue with context, which is well-known in React v0.13, but I hope there's a solution. |
Thanks for the answer, Eric. I've just noticed a mistake I made. I put the Can you explain Resolvers render function to me?
If I comment out the last line, my routing works. Do you mean to execute the if statement block on second render? Maybe you meant to do |
Sure! (This will end up going in the docs to avoid confusion)
Are you saying that by commenting out |
All I'd need to see is the order & how you're outputting the payload + script. Notice how in the React v0.13 Example I use Perhaps I should remove that since many aren't aware of how that works? |
I'm sure it worked, yes. Try the repo i created (make sure you pull the latest, I've positioned the payload, so it's present for the script). Go into your build file in node_modules and comment it out. I've located it to when this renders...
... it stops running the render function for the rest of the app lifetime. You wrote a comment to this if statement: "Server-rendered output, but missing payload". But it runs the first time I navigate – we did delete the payload and the node is populated. Commenting out |
Great debugging! I really appreciate it! I'll dig into this then & push out a fix... |
Sounds good! Really nice work you've done so far! Please ask if you need more info! |
This also seems related to #69, which I'm taking care of in this issue... |
I was able to isolate the bug to specifically // Works with HistoryLocation
React.render(<Root />, document.getElementById("app"));
// HistoryLocation does not update past the first or second route
Resolver.render(() => <Root />, document.getElementById("app")); I'll dig in, but I'd wager it's because after |
static render = function(render, node) { | ||
const initialData = window.__REACT_RESOLVER_PAYLOAD__; | ||
|
||
static render = function(render, node, data = window[PAYLOAD]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the crux of the solution: If the DOM has content but the payload is missing, _fetch the payload & call Resolver.render
with it :)
Sometimes the best answer for recursion is recursion!
This is nearly fixed, but I've also cleaned up the examples a bit as well. |
Confirmed working! I'll merge & patch release this shortly... |
So sleepy...I'll do this tomorrow. |
Happy you found a solution. Sleep tight! |
Uh... shoot. You shouldn't have closed this. |
Please forgive my lack of Github skills. |
Fix HistoryLocation in React v0.13 Example
Hi!
Using HistoryLocation, instead of RefreshLocation as used in the examples, I'm only able to navigate via react-router (both Link component and transitionTo('')) once pr. page load. I've tried to fiddle around with both the source for react-router and react-resolver, but without success. The URL changes, but the
I've reduced my issue down to this repo, which can be run with
npm install
andnpm run watch
. If you uncomment 11th line and comment the 10th line insrc/client.js
, you'll notice that routing works, but obviously serverside rendering does not. This leads me to think this could be a Resolver problem.Anyone having the same issue? Have I done something wrong? I've tried to implement Resolver as per the examples as close as possible.