-
Notifications
You must be signed in to change notification settings - Fork 644
Need to click browser back button twice to exit page in SSR example #313
Comments
Hi, i'm having the same issue. I have tested two options :
|
I'm having the same problem. I think I've solved it by removing the adding and syncing of memoryHistory on the server with the store. This seems to cause problems because the server (with the temporary memoryHistory) can never know the current history of the browser accessing it. This sounds like it defeats the point of server side rendering, but it kind of makes sense to me because the page is still rendered from the server, and nothing should be re-rendered as the current point in browserHistory (from the client side) is exactly the same as the routes that the server rendered from the temporarily created memoryHistory. So basically, history is only added and synced with the store on the client side and therefore it seems to remember all it's current forward / backward states too. Just means one extra action is shot off as soon as the client.js loads without much affect. I'm new to this whole server rendering stuff, so maybe I'm completely wrong. Changed code in
|
@timdorr As @lostpebble said, removing syncHistoryWithStore does solve the issue. But is that the correct way to do? |
do not dispatch action in the first time~
|
This solves the problem when the server has initialised the state and the user already has things in their history. Without this change a superfluous action will be pushed with the same URL that the user is already looking at resulting in that we would need to use the back button twice. Resolves reactjs#313
I have made a PR with what I believe is a fix to this problem, see #403. If you want to try it out today you can change to the following in your "react-router-redux": "dlmr/react-router-redux#fix-inital-server-load-dist" |
thanks @dlmr - i was having this same issue. your PR fixes on my repo. |
This solves the problem when the server has initialised the state and the user already has things in their history. Without this change a superfluous action will be pushed with the same URL that the user is already looking at resulting in that we would need to use the back button twice. Resolves #313
thanks @dlmr for your fixes. |
I'm following the SSR example here:
https://github.com/reactjs/react-router-redux/blob/master/examples/server
Open http://localhost:8080, click browser back button, redux will dispatch router/LOCATION_CHANGE action, the page will remaining in same http://localhost:8080. Click browser back button again, then only the page will be close.
I noticed same issue on other community example as well such as https://github.com/svrcekmichal/universal-react
The text was updated successfully, but these errors were encountered: