Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

52 строки
2.4 KiB

  1. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4. import warning from "warning";
  5. import React from "react";
  6. import PropTypes from "prop-types";
  7. import { createBrowserHistory as createHistory } from "history";
  8. import Router from "./Router";
  9. /**
  10. * The public API for a <Router> that uses HTML5 history.
  11. */
  12. var BrowserRouter = function (_React$Component) {
  13. _inherits(BrowserRouter, _React$Component);
  14. function BrowserRouter() {
  15. var _temp, _this, _ret;
  16. _classCallCheck(this, BrowserRouter);
  17. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  18. args[_key] = arguments[_key];
  19. }
  20. return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.history = createHistory(_this.props), _temp), _possibleConstructorReturn(_this, _ret);
  21. }
  22. BrowserRouter.prototype.componentWillMount = function componentWillMount() {
  23. warning(!this.props.history, "<BrowserRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { BrowserRouter as Router }`.");
  24. };
  25. BrowserRouter.prototype.render = function render() {
  26. return React.createElement(Router, { history: this.history, children: this.props.children });
  27. };
  28. return BrowserRouter;
  29. }(React.Component);
  30. BrowserRouter.propTypes = {
  31. basename: PropTypes.string,
  32. forceRefresh: PropTypes.bool,
  33. getUserConfirmation: PropTypes.func,
  34. keyLength: PropTypes.number,
  35. children: PropTypes.node
  36. };
  37. export default BrowserRouter;