-
Notifications
You must be signed in to change notification settings - Fork 959
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
Page is refreshed by calling history.go(), while history.back() isn't #824
Comments
Can you clarify what exactly you're doing? If you invoke
I'm not sure why you call |
@StringEpsilon Thank you for the answer! My goal is to trigger a new route in the child iframe react app without page refresh. But when I try smth like I did some clicks in the iframe app (RR did its thing). And then I did Cool! I thought. I can trigger the iframe history from the parent window. But my initial goal was not about So, how I can do that? Imagine, I'm on the following url I also tried this stuff without any iframes, to simplify the task: So, there is my question, how to do this? How to change a route in an iframed app? |
History version 5 has support for custom window objects to enable easier use of iframes (see #624 ). I'm afraid you just have to wait for react-router version 6 to come out or risk the beta. Also, I think you should probably seek advice on stackoverflow and or reactiflux on this. https://www.reactiflux.com/ This is clearly a support question and not a feature request or bug report. |
@StringEpsilon Thank you for sharing the 624, but it's not the case. The 624 PR is about desyncronization of history objects and about the ability to set such behavior. Well, I believe it is a bug or at least a feature request. I was asking for an advise only after discovering an issue that works not as expected. I will try to explain why I think this is a bug/feature request. The whole thing is not about iframes. It's just when such behavior is crucial instead of optional.
Unfortunately, while delta in From the other hand, if React Router works correctly when I call I think, that this is a bug or missing functionality. |
Unfortunatly, there is no API to get notified about This library would need to monkeypatch the two functions to add in events or a callback. |
It sounds like you want this library to be something it's not. This library isn't meant to replace the browser's built-in history API. It's just a thin layer the router uses to communicate with the browser. But users are still free to call the browser's built-in methods however they wish. |
We have iframe based micro-frontends. There is a need of changing the state of the inside app from outside one without full-reloading of the inside one.
There is
<BrowserRouter />
which uses Native History API.I have tested the behavior on single app without any iframes.
When I click anchors in the app, React router doesn't refresh the whole app, and replaces parts of the app. In my case -- it's pagination.
I can call
window.history.back()
and it will not trigger page refresh.The same, I can do
window.history.go(-1)
and it will not trigger page referesh.Then I decided what if I make
window.history.pushState(null, null, 'page/2')
and callwindow.history.go()
-- page will be refreshed from scratch.I can solve my task by replacing
BrowserRouter
byRouter
and exposinghistory
object towindow.ReactRouterHistory
, but I think it's too much, when I can dowindow.history.back()
without a page refresh.Is it a bug? Why the page is fully refreshed by
go()
, but isn't whengo(-1)
?Is there a proper way to do this?
Thank you!
The text was updated successfully, but these errors were encountered: