UNPKG

25.6 kBJavaScriptView Raw
1'use strict';
2
3function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
5var React = _interopDefault(require('react'));
6var PropTypes = _interopDefault(require('prop-types'));
7var history = require('history');
8var warning = _interopDefault(require('tiny-warning'));
9var createContext = _interopDefault(require('mini-create-react-context'));
10var invariant = _interopDefault(require('tiny-invariant'));
11var pathToRegexp = _interopDefault(require('path-to-regexp'));
12var reactIs = require('react-is');
13var hoistStatics = _interopDefault(require('hoist-non-react-statics'));
14
15function _extends() {
16 _extends = Object.assign || function (target) {
17 for (var i = 1; i < arguments.length; i++) {
18 var source = arguments[i];
19
20 for (var key in source) {
21 if (Object.prototype.hasOwnProperty.call(source, key)) {
22 target[key] = source[key];
23 }
24 }
25 }
26
27 return target;
28 };
29
30 return _extends.apply(this, arguments);
31}
32
33function _inheritsLoose(subClass, superClass) {
34 subClass.prototype = Object.create(superClass.prototype);
35 subClass.prototype.constructor = subClass;
36
37 _setPrototypeOf(subClass, superClass);
38}
39
40function _setPrototypeOf(o, p) {
41 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
42 o.__proto__ = p;
43 return o;
44 };
45
46 return _setPrototypeOf(o, p);
47}
48
49function _objectWithoutPropertiesLoose(source, excluded) {
50 if (source == null) return {};
51 var target = {};
52 var sourceKeys = Object.keys(source);
53 var key, i;
54
55 for (i = 0; i < sourceKeys.length; i++) {
56 key = sourceKeys[i];
57 if (excluded.indexOf(key) >= 0) continue;
58 target[key] = source[key];
59 }
60
61 return target;
62}
63
64// TODO: Replace with React.createContext once we can assume React 16+
65
66var createNamedContext = function createNamedContext(name) {
67 var context = createContext();
68 context.displayName = name;
69 return context;
70};
71
72var historyContext = /*#__PURE__*/createNamedContext("Router-History");
73
74var context = /*#__PURE__*/createNamedContext("Router");
75
76/**
77 * The public API for putting history on context.
78 */
79
80var Router = /*#__PURE__*/function (_React$Component) {
81 _inheritsLoose(Router, _React$Component);
82
83 Router.computeRootMatch = function computeRootMatch(pathname) {
84 return {
85 path: "/",
86 url: "/",
87 params: {},
88 isExact: pathname === "/"
89 };
90 };
91
92 function Router(props) {
93 var _this;
94
95 _this = _React$Component.call(this, props) || this;
96 _this.state = {
97 location: props.history.location
98 }; // This is a bit of a hack. We have to start listening for location
99 // changes here in the constructor in case there are any <Redirect>s
100 // on the initial render. If there are, they will replace/push when
101 // they mount and since cDM fires in children before parents, we may
102 // get a new location before the <Router> is mounted.
103
104 _this._isMounted = false;
105 _this._pendingLocation = null;
106
107 if (!props.staticContext) {
108 _this.unlisten = props.history.listen(function (location) {
109 _this._pendingLocation = location;
110 });
111 }
112
113 return _this;
114 }
115
116 var _proto = Router.prototype;
117
118 _proto.componentDidMount = function componentDidMount() {
119 var _this2 = this;
120
121 this._isMounted = true;
122
123 if (this.unlisten) {
124 // Any pre-mount location changes have been captured at
125 // this point, so unregister the listener.
126 this.unlisten();
127 }
128
129 if (!this.props.staticContext) {
130 this.unlisten = this.props.history.listen(function (location) {
131 if (_this2._isMounted) {
132 _this2.setState({
133 location: location
134 });
135 }
136 });
137 }
138
139 if (this._pendingLocation) {
140 this.setState({
141 location: this._pendingLocation
142 });
143 }
144 };
145
146 _proto.componentWillUnmount = function componentWillUnmount() {
147 if (this.unlisten) {
148 this.unlisten();
149 this._isMounted = false;
150 this._pendingLocation = null;
151 }
152 };
153
154 _proto.render = function render() {
155 return /*#__PURE__*/React.createElement(context.Provider, {
156 value: {
157 history: this.props.history,
158 location: this.state.location,
159 match: Router.computeRootMatch(this.state.location.pathname),
160 staticContext: this.props.staticContext
161 }
162 }, /*#__PURE__*/React.createElement(historyContext.Provider, {
163 children: this.props.children || null,
164 value: this.props.history
165 }));
166 };
167
168 return Router;
169}(React.Component);
170
171{
172 Router.propTypes = {
173 children: PropTypes.node,
174 history: PropTypes.object.isRequired,
175 staticContext: PropTypes.object
176 };
177
178 Router.prototype.componentDidUpdate = function (prevProps) {
179 warning(prevProps.history === this.props.history, "You cannot change <Router history>") ;
180 };
181}
182
183/**
184 * The public API for a <Router> that stores location in memory.
185 */
186
187var MemoryRouter = /*#__PURE__*/function (_React$Component) {
188 _inheritsLoose(MemoryRouter, _React$Component);
189
190 function MemoryRouter() {
191 var _this;
192
193 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
194 args[_key] = arguments[_key];
195 }
196
197 _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
198 _this.history = history.createMemoryHistory(_this.props);
199 return _this;
200 }
201
202 var _proto = MemoryRouter.prototype;
203
204 _proto.render = function render() {
205 return /*#__PURE__*/React.createElement(Router, {
206 history: this.history,
207 children: this.props.children
208 });
209 };
210
211 return MemoryRouter;
212}(React.Component);
213
214{
215 MemoryRouter.propTypes = {
216 initialEntries: PropTypes.array,
217 initialIndex: PropTypes.number,
218 getUserConfirmation: PropTypes.func,
219 keyLength: PropTypes.number,
220 children: PropTypes.node
221 };
222
223 MemoryRouter.prototype.componentDidMount = function () {
224 warning(!this.props.history, "<MemoryRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { MemoryRouter as Router }`.") ;
225 };
226}
227
228var Lifecycle = /*#__PURE__*/function (_React$Component) {
229 _inheritsLoose(Lifecycle, _React$Component);
230
231 function Lifecycle() {
232 return _React$Component.apply(this, arguments) || this;
233 }
234
235 var _proto = Lifecycle.prototype;
236
237 _proto.componentDidMount = function componentDidMount() {
238 if (this.props.onMount) this.props.onMount.call(this, this);
239 };
240
241 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
242 if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);
243 };
244
245 _proto.componentWillUnmount = function componentWillUnmount() {
246 if (this.props.onUnmount) this.props.onUnmount.call(this, this);
247 };
248
249 _proto.render = function render() {
250 return null;
251 };
252
253 return Lifecycle;
254}(React.Component);
255
256/**
257 * The public API for prompting the user before navigating away from a screen.
258 */
259
260function Prompt(_ref) {
261 var message = _ref.message,
262 _ref$when = _ref.when,
263 when = _ref$when === void 0 ? true : _ref$when;
264 return /*#__PURE__*/React.createElement(context.Consumer, null, function (context) {
265 !context ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
266 if (!when || context.staticContext) return null;
267 var method = context.history.block;
268 return /*#__PURE__*/React.createElement(Lifecycle, {
269 onMount: function onMount(self) {
270 self.release = method(message);
271 },
272 onUpdate: function onUpdate(self, prevProps) {
273 if (prevProps.message !== message) {
274 self.release();
275 self.release = method(message);
276 }
277 },
278 onUnmount: function onUnmount(self) {
279 self.release();
280 },
281 message: message
282 });
283 });
284}
285
286{
287 var messageType = PropTypes.oneOfType([PropTypes.func, PropTypes.string]);
288 Prompt.propTypes = {
289 when: PropTypes.bool,
290 message: messageType.isRequired
291 };
292}
293
294var cache = {};
295var cacheLimit = 10000;
296var cacheCount = 0;
297
298function compilePath(path) {
299 if (cache[path]) return cache[path];
300 var generator = pathToRegexp.compile(path);
301
302 if (cacheCount < cacheLimit) {
303 cache[path] = generator;
304 cacheCount++;
305 }
306
307 return generator;
308}
309/**
310 * Public API for generating a URL pathname from a path and parameters.
311 */
312
313
314function generatePath(path, params) {
315 if (path === void 0) {
316 path = "/";
317 }
318
319 if (params === void 0) {
320 params = {};
321 }
322
323 return path === "/" ? path : compilePath(path)(params, {
324 pretty: true
325 });
326}
327
328/**
329 * The public API for navigating programmatically with a component.
330 */
331
332function Redirect(_ref) {
333 var computedMatch = _ref.computedMatch,
334 to = _ref.to,
335 _ref$push = _ref.push,
336 push = _ref$push === void 0 ? false : _ref$push;
337 return /*#__PURE__*/React.createElement(context.Consumer, null, function (context) {
338 !context ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
339 var history$1 = context.history,
340 staticContext = context.staticContext;
341 var method = push ? history$1.push : history$1.replace;
342 var location = history.createLocation(computedMatch ? typeof to === "string" ? generatePath(to, computedMatch.params) : _extends({}, to, {
343 pathname: generatePath(to.pathname, computedMatch.params)
344 }) : to); // When rendering in a static context,
345 // set the new location immediately.
346
347 if (staticContext) {
348 method(location);
349 return null;
350 }
351
352 return /*#__PURE__*/React.createElement(Lifecycle, {
353 onMount: function onMount() {
354 method(location);
355 },
356 onUpdate: function onUpdate(self, prevProps) {
357 var prevLocation = history.createLocation(prevProps.to);
358
359 if (!history.locationsAreEqual(prevLocation, _extends({}, location, {
360 key: prevLocation.key
361 }))) {
362 method(location);
363 }
364 },
365 to: to
366 });
367 });
368}
369
370{
371 Redirect.propTypes = {
372 push: PropTypes.bool,
373 from: PropTypes.string,
374 to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired
375 };
376}
377
378var cache$1 = {};
379var cacheLimit$1 = 10000;
380var cacheCount$1 = 0;
381
382function compilePath$1(path, options) {
383 var cacheKey = "" + options.end + options.strict + options.sensitive;
384 var pathCache = cache$1[cacheKey] || (cache$1[cacheKey] = {});
385 if (pathCache[path]) return pathCache[path];
386 var keys = [];
387 var regexp = pathToRegexp(path, keys, options);
388 var result = {
389 regexp: regexp,
390 keys: keys
391 };
392
393 if (cacheCount$1 < cacheLimit$1) {
394 pathCache[path] = result;
395 cacheCount$1++;
396 }
397
398 return result;
399}
400/**
401 * Public API for matching a URL pathname to a path.
402 */
403
404
405function matchPath(pathname, options) {
406 if (options === void 0) {
407 options = {};
408 }
409
410 if (typeof options === "string" || Array.isArray(options)) {
411 options = {
412 path: options
413 };
414 }
415
416 var _options = options,
417 path = _options.path,
418 _options$exact = _options.exact,
419 exact = _options$exact === void 0 ? false : _options$exact,
420 _options$strict = _options.strict,
421 strict = _options$strict === void 0 ? false : _options$strict,
422 _options$sensitive = _options.sensitive,
423 sensitive = _options$sensitive === void 0 ? false : _options$sensitive;
424 var paths = [].concat(path);
425 return paths.reduce(function (matched, path) {
426 if (!path && path !== "") return null;
427 if (matched) return matched;
428
429 var _compilePath = compilePath$1(path, {
430 end: exact,
431 strict: strict,
432 sensitive: sensitive
433 }),
434 regexp = _compilePath.regexp,
435 keys = _compilePath.keys;
436
437 var match = regexp.exec(pathname);
438 if (!match) return null;
439 var url = match[0],
440 values = match.slice(1);
441 var isExact = pathname === url;
442 if (exact && !isExact) return null;
443 return {
444 path: path,
445 // the path used to match
446 url: path === "/" && url === "" ? "/" : url,
447 // the matched portion of the URL
448 isExact: isExact,
449 // whether or not we matched exactly
450 params: keys.reduce(function (memo, key, index) {
451 memo[key.name] = values[index];
452 return memo;
453 }, {})
454 };
455 }, null);
456}
457
458function isEmptyChildren(children) {
459 return React.Children.count(children) === 0;
460}
461
462function evalChildrenDev(children, props, path) {
463 var value = children(props);
464 warning(value !== undefined, "You returned `undefined` from the `children` function of " + ("<Route" + (path ? " path=\"" + path + "\"" : "") + ">, but you ") + "should have returned a React element or `null`") ;
465 return value || null;
466}
467/**
468 * The public API for matching a single path and rendering.
469 */
470
471
472var Route = /*#__PURE__*/function (_React$Component) {
473 _inheritsLoose(Route, _React$Component);
474
475 function Route() {
476 return _React$Component.apply(this, arguments) || this;
477 }
478
479 var _proto = Route.prototype;
480
481 _proto.render = function render() {
482 var _this = this;
483
484 return /*#__PURE__*/React.createElement(context.Consumer, null, function (context$1) {
485 !context$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
486 var location = _this.props.location || context$1.location;
487 var match = _this.props.computedMatch ? _this.props.computedMatch // <Switch> already computed the match for us
488 : _this.props.path ? matchPath(location.pathname, _this.props) : context$1.match;
489
490 var props = _extends({}, context$1, {
491 location: location,
492 match: match
493 });
494
495 var _this$props = _this.props,
496 children = _this$props.children,
497 component = _this$props.component,
498 render = _this$props.render; // Preact uses an empty array as children by
499 // default, so use null if that's the case.
500
501 if (Array.isArray(children) && isEmptyChildren(children)) {
502 children = null;
503 }
504
505 return /*#__PURE__*/React.createElement(context.Provider, {
506 value: props
507 }, props.match ? children ? typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : children : component ? /*#__PURE__*/React.createElement(component, props) : render ? render(props) : null : typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : null);
508 });
509 };
510
511 return Route;
512}(React.Component);
513
514{
515 Route.propTypes = {
516 children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
517 component: function component(props, propName) {
518 if (props[propName] && !reactIs.isValidElementType(props[propName])) {
519 return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component");
520 }
521 },
522 exact: PropTypes.bool,
523 location: PropTypes.object,
524 path: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
525 render: PropTypes.func,
526 sensitive: PropTypes.bool,
527 strict: PropTypes.bool
528 };
529
530 Route.prototype.componentDidMount = function () {
531 warning(!(this.props.children && !isEmptyChildren(this.props.children) && this.props.component), "You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored") ;
532 warning(!(this.props.children && !isEmptyChildren(this.props.children) && this.props.render), "You should not use <Route render> and <Route children> in the same route; <Route render> will be ignored") ;
533 warning(!(this.props.component && this.props.render), "You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored") ;
534 };
535
536 Route.prototype.componentDidUpdate = function (prevProps) {
537 warning(!(this.props.location && !prevProps.location), '<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.') ;
538 warning(!(!this.props.location && prevProps.location), '<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.') ;
539 };
540}
541
542function addLeadingSlash(path) {
543 return path.charAt(0) === "/" ? path : "/" + path;
544}
545
546function addBasename(basename, location) {
547 if (!basename) return location;
548 return _extends({}, location, {
549 pathname: addLeadingSlash(basename) + location.pathname
550 });
551}
552
553function stripBasename(basename, location) {
554 if (!basename) return location;
555 var base = addLeadingSlash(basename);
556 if (location.pathname.indexOf(base) !== 0) return location;
557 return _extends({}, location, {
558 pathname: location.pathname.substr(base.length)
559 });
560}
561
562function createURL(location) {
563 return typeof location === "string" ? location : history.createPath(location);
564}
565
566function staticHandler(methodName) {
567 return function () {
568 invariant(false, "You cannot %s with <StaticRouter>", methodName) ;
569 };
570}
571
572function noop() {}
573/**
574 * The public top-level API for a "static" <Router>, so-called because it
575 * can't actually change the current location. Instead, it just records
576 * location changes in a context object. Useful mainly in testing and
577 * server-rendering scenarios.
578 */
579
580
581var StaticRouter = /*#__PURE__*/function (_React$Component) {
582 _inheritsLoose(StaticRouter, _React$Component);
583
584 function StaticRouter() {
585 var _this;
586
587 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
588 args[_key] = arguments[_key];
589 }
590
591 _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
592
593 _this.handlePush = function (location) {
594 return _this.navigateTo(location, "PUSH");
595 };
596
597 _this.handleReplace = function (location) {
598 return _this.navigateTo(location, "REPLACE");
599 };
600
601 _this.handleListen = function () {
602 return noop;
603 };
604
605 _this.handleBlock = function () {
606 return noop;
607 };
608
609 return _this;
610 }
611
612 var _proto = StaticRouter.prototype;
613
614 _proto.navigateTo = function navigateTo(location, action) {
615 var _this$props = this.props,
616 _this$props$basename = _this$props.basename,
617 basename = _this$props$basename === void 0 ? "" : _this$props$basename,
618 _this$props$context = _this$props.context,
619 context = _this$props$context === void 0 ? {} : _this$props$context;
620 context.action = action;
621 context.location = addBasename(basename, history.createLocation(location));
622 context.url = createURL(context.location);
623 };
624
625 _proto.render = function render() {
626 var _this$props2 = this.props,
627 _this$props2$basename = _this$props2.basename,
628 basename = _this$props2$basename === void 0 ? "" : _this$props2$basename,
629 _this$props2$context = _this$props2.context,
630 context = _this$props2$context === void 0 ? {} : _this$props2$context,
631 _this$props2$location = _this$props2.location,
632 location = _this$props2$location === void 0 ? "/" : _this$props2$location,
633 rest = _objectWithoutPropertiesLoose(_this$props2, ["basename", "context", "location"]);
634
635 var history$1 = {
636 createHref: function createHref(path) {
637 return addLeadingSlash(basename + createURL(path));
638 },
639 action: "POP",
640 location: stripBasename(basename, history.createLocation(location)),
641 push: this.handlePush,
642 replace: this.handleReplace,
643 go: staticHandler("go"),
644 goBack: staticHandler("goBack"),
645 goForward: staticHandler("goForward"),
646 listen: this.handleListen,
647 block: this.handleBlock
648 };
649 return /*#__PURE__*/React.createElement(Router, _extends({}, rest, {
650 history: history$1,
651 staticContext: context
652 }));
653 };
654
655 return StaticRouter;
656}(React.Component);
657
658{
659 StaticRouter.propTypes = {
660 basename: PropTypes.string,
661 context: PropTypes.object,
662 location: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
663 };
664
665 StaticRouter.prototype.componentDidMount = function () {
666 warning(!this.props.history, "<StaticRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { StaticRouter as Router }`.") ;
667 };
668}
669
670/**
671 * The public API for rendering the first <Route> that matches.
672 */
673
674var Switch = /*#__PURE__*/function (_React$Component) {
675 _inheritsLoose(Switch, _React$Component);
676
677 function Switch() {
678 return _React$Component.apply(this, arguments) || this;
679 }
680
681 var _proto = Switch.prototype;
682
683 _proto.render = function render() {
684 var _this = this;
685
686 return /*#__PURE__*/React.createElement(context.Consumer, null, function (context) {
687 !context ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
688 var location = _this.props.location || context.location;
689 var element, match; // We use React.Children.forEach instead of React.Children.toArray().find()
690 // here because toArray adds keys to all child elements and we do not want
691 // to trigger an unmount/remount for two <Route>s that render the same
692 // component at different URLs.
693
694 React.Children.forEach(_this.props.children, function (child) {
695 if (match == null && /*#__PURE__*/React.isValidElement(child)) {
696 element = child;
697 var path = child.props.path || child.props.from;
698 match = path ? matchPath(location.pathname, _extends({}, child.props, {
699 path: path
700 })) : context.match;
701 }
702 });
703 return match ? /*#__PURE__*/React.cloneElement(element, {
704 location: location,
705 computedMatch: match
706 }) : null;
707 });
708 };
709
710 return Switch;
711}(React.Component);
712
713{
714 Switch.propTypes = {
715 children: PropTypes.node,
716 location: PropTypes.object
717 };
718
719 Switch.prototype.componentDidUpdate = function (prevProps) {
720 warning(!(this.props.location && !prevProps.location), '<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.') ;
721 warning(!(!this.props.location && prevProps.location), '<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.') ;
722 };
723}
724
725/**
726 * A public higher-order component to access the imperative API
727 */
728
729function withRouter(Component) {
730 var displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
731
732 var C = function C(props) {
733 var wrappedComponentRef = props.wrappedComponentRef,
734 remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
735
736 return /*#__PURE__*/React.createElement(context.Consumer, null, function (context) {
737 !context ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : void 0;
738 return /*#__PURE__*/React.createElement(Component, _extends({}, remainingProps, context, {
739 ref: wrappedComponentRef
740 }));
741 });
742 };
743
744 C.displayName = displayName;
745 C.WrappedComponent = Component;
746
747 {
748 C.propTypes = {
749 wrappedComponentRef: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object])
750 };
751 }
752
753 return hoistStatics(C, Component);
754}
755
756var useContext = React.useContext;
757function useHistory() {
758 {
759 !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : void 0;
760 }
761
762 return useContext(historyContext);
763}
764function useLocation() {
765 {
766 !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useLocation()") : void 0;
767 }
768
769 return useContext(context).location;
770}
771function useParams() {
772 {
773 !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useParams()") : void 0;
774 }
775
776 var match = useContext(context).match;
777 return match ? match.params : {};
778}
779function useRouteMatch(path) {
780 {
781 !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useRouteMatch()") : void 0;
782 }
783
784 var location = useLocation();
785 var match = useContext(context).match;
786 return path ? matchPath(location.pathname, path) : match;
787}
788
789{
790 if (typeof window !== "undefined") {
791 var global = window;
792 var key = "__react_router_build__";
793 var buildNames = {
794 cjs: "CommonJS",
795 esm: "ES modules",
796 umd: "UMD"
797 };
798
799 if (global[key] && global[key] !== "cjs") {
800 var initialBuildName = buildNames[global[key]];
801 var secondaryBuildName = buildNames["cjs"]; // TODO: Add link to article that explains in detail how to avoid
802 // loading 2 different builds.
803
804 throw new Error("You are loading the " + secondaryBuildName + " build of React Router " + ("on a page that is already running the " + initialBuildName + " ") + "build, so things won't work right.");
805 }
806
807 global[key] = "cjs";
808 }
809}
810
811exports.MemoryRouter = MemoryRouter;
812exports.Prompt = Prompt;
813exports.Redirect = Redirect;
814exports.Route = Route;
815exports.Router = Router;
816exports.StaticRouter = StaticRouter;
817exports.Switch = Switch;
818exports.__HistoryContext = historyContext;
819exports.__RouterContext = context;
820exports.generatePath = generatePath;
821exports.matchPath = matchPath;
822exports.useHistory = useHistory;
823exports.useLocation = useLocation;
824exports.useParams = useParams;
825exports.useRouteMatch = useRouteMatch;
826exports.withRouter = withRouter;
827//# sourceMappingURL=react-router.js.map