mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
36 lines
962 B
JavaScript
36 lines
962 B
JavaScript
import React from "react";
|
|
import { Router } from "react-router";
|
|
import { createHashHistory as createHistory } from "history";
|
|
import PropTypes from "prop-types";
|
|
import warning from "tiny-warning";
|
|
|
|
/**
|
|
* The public API for a <Router> that uses window.location.hash.
|
|
*/
|
|
class HashRouter extends React.Component {
|
|
history = createHistory(this.props);
|
|
|
|
render() {
|
|
return <Router history={this.history} children={this.props.children} />;
|
|
}
|
|
}
|
|
|
|
if (__DEV__) {
|
|
HashRouter.propTypes = {
|
|
basename: PropTypes.string,
|
|
children: PropTypes.node,
|
|
getUserConfirmation: PropTypes.func,
|
|
hashType: PropTypes.oneOf(["hashbang", "noslash", "slash"])
|
|
};
|
|
|
|
HashRouter.prototype.componentDidMount = function() {
|
|
warning(
|
|
!this.props.history,
|
|
"<HashRouter> ignores the history prop. To use a custom history, " +
|
|
"use `import { Router }` instead of `import { HashRouter as Router }`."
|
|
);
|
|
};
|
|
}
|
|
|
|
export default HashRouter;
|