mirror of
https://github.com/twisterarmy/twister-react.git
synced 2025-01-26 06:34:23 +00:00
30 lines
616 B
JavaScript
30 lines
616 B
JavaScript
|
"use strict";
|
||
|
|
||
|
var invariant = require("react/lib/invariant");
|
||
|
var canUseDOM = require("react/lib/ExecutionEnvironment").canUseDOM;
|
||
|
|
||
|
var History = {
|
||
|
|
||
|
/**
|
||
|
* The current number of entries in the history.
|
||
|
*
|
||
|
* Note: This property is read-only.
|
||
|
*/
|
||
|
length: 1,
|
||
|
|
||
|
/**
|
||
|
* Sends the browser back one entry in the history.
|
||
|
*/
|
||
|
back: function back() {
|
||
|
invariant(canUseDOM, "Cannot use History.back without a DOM");
|
||
|
|
||
|
// Do this first so that History.length will
|
||
|
// be accurate in location change listeners.
|
||
|
History.length -= 1;
|
||
|
|
||
|
window.history.back();
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
module.exports = History;
|