Projekt

Obecné

Profil

Stáhnout (978 Bajtů) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
import React from "react";
2
import { Router } from "react-router";
3
import { createBrowserHistory as createHistory } from "history";
4
import PropTypes from "prop-types";
5
import warning from "tiny-warning";
6
7
/**
8
 * The public API for a <Router> that uses HTML5 history.
9
 */
10
class BrowserRouter extends React.Component {
11
  history = createHistory(this.props);
12
13
  render() {
14
    return <Router history={this.history} children={this.props.children} />;
15
  }
16
}
17
18
if (__DEV__) {
19
  BrowserRouter.propTypes = {
20
    basename: PropTypes.string,
21
    children: PropTypes.node,
22
    forceRefresh: PropTypes.bool,
23
    getUserConfirmation: PropTypes.func,
24
    keyLength: PropTypes.number
25
  };
26
27
  BrowserRouter.prototype.componentDidMount = function() {
28
    warning(
29
      !this.props.history,
30
      "<BrowserRouter> ignores the history prop. To use a custom history, " +
31
        "use `import { Router }` instead of `import { BrowserRouter as Router }`."
32
    );
33
  };
34
}
35
36
export default BrowserRouter;