Skip to content

Commit 8897782

Browse files
committed
Always goBack when using RefreshLocation
1 parent efdd34d commit 8897782

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

modules/utils/History.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
44
var History = {
55

66
/**
7-
* Sends the browser back one entry in the history, if one is available.
7+
* Sends the browser back one entry in the history.
88
*/
99
back: function () {
1010
invariant(

modules/utils/createRouter.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,23 @@ function createRouter(options) {
257257
},
258258

259259
/**
260-
* Transitions to the previous URL. Returns true if the router
261-
* was able to go back, false otherwise.
260+
* Transitions to the previous URL if one is available. Returns true if the
261+
* router was able to go back, false otherwise.
262+
*
263+
* Note: The router only tracks history entries in your application, not the
264+
* current browser session, so you can safely call this function without guarding
265+
* against sending the user back to some other site. However, when using
266+
* RefreshLocation (which is the fallback for HistoryLocation in browsers that
267+
* don't support HTML5 history) this method will *always* send the client back
268+
* because we cannot reliably track history length.
262269
*/
263270
goBack: function () {
264271
invariant(
265272
typeof location !== 'string',
266273
'You cannot use goBack with a static location'
267274
);
268275

269-
if (History.length > 1) {
276+
if (History.length > 1 || location === RefreshLocation) {
270277
location.pop();
271278
return true;
272279
}

0 commit comments

Comments
 (0)