react-router-dom 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,12 +4,12 @@
4
4
  (factory((global.ReactRouterDOM = {}),global.React));
5
5
  }(this, (function (exports,React) { 'use strict';
6
6
 
7
- React = React && React.hasOwnProperty('default') ? React['default'] : React;
7
+ var React__default = 'default' in React ? React['default'] : React;
8
8
 
9
- var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
9
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10
10
 
11
11
  function unwrapExports (x) {
12
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x;
12
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
13
13
  }
14
14
 
15
15
  function createCommonjsModule(fn, module) {
@@ -774,124 +774,56 @@
774
774
  return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
775
775
  };
776
776
 
777
- /**
778
- * Copyright (c) 2013-present, Facebook, Inc.
779
- *
780
- * This source code is licensed under the MIT license found in the
781
- * LICENSE file in the root directory of this source tree.
782
- *
783
- *
784
- */
785
-
786
- function makeEmptyFunction(arg) {
787
- return function () {
788
- return arg;
789
- };
790
- }
791
-
792
- /**
793
- * This function accepts and discards inputs; it has no side effects. This is
794
- * primarily useful idiomatically for overridable function endpoints which
795
- * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
796
- */
797
- var emptyFunction$1 = function emptyFunction() {};
798
-
799
- emptyFunction$1.thatReturns = makeEmptyFunction;
800
- emptyFunction$1.thatReturnsFalse = makeEmptyFunction(false);
801
- emptyFunction$1.thatReturnsTrue = makeEmptyFunction(true);
802
- emptyFunction$1.thatReturnsNull = makeEmptyFunction(null);
803
- emptyFunction$1.thatReturnsThis = function () {
804
- return this;
805
- };
806
- emptyFunction$1.thatReturnsArgument = function (arg) {
807
- return arg;
808
- };
809
-
810
- var emptyFunction_1 = emptyFunction$1;
811
-
812
- /**
813
- * Similar to invariant but only logs a warning if the condition is not met.
814
- * This can be used to log issues in development environments in critical
815
- * paths. Removing the logging code for production environments will keep the
816
- * same logic and follow the same code paths.
817
- */
818
-
819
- var warning = emptyFunction_1;
820
-
821
- {
822
- var printWarning$2 = function printWarning(format) {
823
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
824
- args[_key - 1] = arguments[_key];
777
+ function warning(condition, message) {
778
+ {
779
+ if (condition) {
780
+ return;
825
781
  }
826
782
 
827
- var argIndex = 0;
828
- var message = 'Warning: ' + format.replace(/%s/g, function () {
829
- return args[argIndex++];
830
- });
783
+ var text = "Warning: " + message;
784
+
831
785
  if (typeof console !== 'undefined') {
832
- console.error(message);
786
+ console.warn(text);
833
787
  }
788
+
834
789
  try {
835
- // --- Welcome to debugging React ---
836
- // This error was thrown as a convenience so that you can use this stack
837
- // to find the callsite that caused this warning to fire.
838
- throw new Error(message);
790
+ throw Error(text);
839
791
  } catch (x) {}
840
- };
841
-
842
- warning = function warning(condition, format) {
843
- if (format === undefined) {
844
- throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
845
- }
846
-
847
- if (format.indexOf('Failed Composite propType: ') === 0) {
848
- return; // Ignore CompositeComponent proptype check.
849
- }
850
-
851
- if (!condition) {
852
- for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
853
- args[_key2 - 2] = arguments[_key2];
854
- }
855
-
856
- printWarning$2.apply(undefined, [format].concat(args));
857
- }
858
- };
792
+ }
859
793
  }
860
794
 
861
- var warning_1 = warning;
862
-
863
- var implementation = createCommonjsModule(function (module, exports) {
864
-
865
- exports.__esModule = true;
866
-
867
-
868
-
869
- var _react2 = _interopRequireDefault(React);
870
-
871
-
872
-
873
- var _propTypes2 = _interopRequireDefault(propTypes);
874
-
875
-
876
-
877
- var _gud2 = _interopRequireDefault(gud);
878
-
879
-
880
-
881
- var _warning2 = _interopRequireDefault(warning_1);
882
-
883
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
795
+ function _defineProperty(obj, key, value) {
796
+ if (key in obj) {
797
+ Object.defineProperty(obj, key, {
798
+ value: value,
799
+ enumerable: true,
800
+ configurable: true,
801
+ writable: true
802
+ });
803
+ } else {
804
+ obj[key] = value;
805
+ }
884
806
 
885
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
807
+ return obj;
808
+ }
886
809
 
887
- 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; }
810
+ function _inheritsLoose(subClass, superClass) {
811
+ subClass.prototype = Object.create(superClass.prototype);
812
+ subClass.prototype.constructor = subClass;
813
+ subClass.__proto__ = superClass;
814
+ }
888
815
 
889
- 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; }
816
+ function _assertThisInitialized(self) {
817
+ if (self === void 0) {
818
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
819
+ }
890
820
 
891
- var MAX_SIGNED_31_BIT_INT = 1073741823;
821
+ return self;
822
+ }
892
823
 
893
- // Inlined Object.is polyfill.
824
+ var MAX_SIGNED_31_BIT_INT = 1073741823; // Inlined Object.is polyfill.
894
825
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
826
+
895
827
  function objectIs(x, y) {
896
828
  if (x === y) {
897
829
  return x !== 0 || 1 / x === 1 / y;
@@ -928,43 +860,50 @@
928
860
  }
929
861
 
930
862
  function createReactContext(defaultValue, calculateChangedBits) {
931
- var _Provider$childContex, _Consumer$contextType;
863
+ var _defineProperty2, _defineProperty3;
932
864
 
933
- var contextProp = '__create-react-context-' + (0, _gud2.default)() + '__';
865
+ var contextProp = '__create-react-context-' + gud() + '__';
934
866
 
935
- var Provider = function (_Component) {
936
- _inherits(Provider, _Component);
867
+ var Provider =
868
+ /*#__PURE__*/
869
+ function (_Component) {
870
+ _inheritsLoose(Provider, _Component);
937
871
 
938
872
  function Provider() {
939
- var _temp, _this, _ret;
940
-
941
- _classCallCheck(this, Provider);
873
+ var _this;
942
874
 
943
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
875
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
944
876
  args[_key] = arguments[_key];
945
877
  }
946
878
 
947
- return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.emitter = createEventEmitter(_this.props.value), _temp), _possibleConstructorReturn(_this, _ret);
879
+ _this = _Component.call.apply(_Component, [this].concat(args)) || this;
880
+
881
+ _defineProperty(_assertThisInitialized(_this), "emitter", createEventEmitter(_this.props.value));
882
+
883
+ return _this;
948
884
  }
949
885
 
950
- Provider.prototype.getChildContext = function getChildContext() {
886
+ var _proto = Provider.prototype;
887
+
888
+ _proto.getChildContext = function getChildContext() {
951
889
  var _ref;
952
890
 
953
891
  return _ref = {}, _ref[contextProp] = this.emitter, _ref;
954
892
  };
955
893
 
956
- Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
894
+ _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
957
895
  if (this.props.value !== nextProps.value) {
958
896
  var oldValue = this.props.value;
959
897
  var newValue = nextProps.value;
960
- var changedBits = void 0;
898
+ var changedBits;
961
899
 
962
900
  if (objectIs(oldValue, newValue)) {
963
901
  changedBits = 0; // No change
964
902
  } else {
965
903
  changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
904
+
966
905
  {
967
- (0, _warning2.default)((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits);
906
+ warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: ' + changedBits);
968
907
  }
969
908
 
970
909
  changedBits |= 0;
@@ -976,61 +915,73 @@
976
915
  }
977
916
  };
978
917
 
979
- Provider.prototype.render = function render() {
918
+ _proto.render = function render() {
980
919
  return this.props.children;
981
920
  };
982
921
 
983
922
  return Provider;
984
923
  }(React.Component);
985
924
 
986
- Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = _propTypes2.default.object.isRequired, _Provider$childContex);
925
+ _defineProperty(Provider, "childContextTypes", (_defineProperty2 = {}, _defineProperty2[contextProp] = propTypes.object.isRequired, _defineProperty2));
987
926
 
988
- var Consumer = function (_Component2) {
989
- _inherits(Consumer, _Component2);
927
+ var Consumer =
928
+ /*#__PURE__*/
929
+ function (_Component2) {
930
+ _inheritsLoose(Consumer, _Component2);
990
931
 
991
932
  function Consumer() {
992
- var _temp2, _this2, _ret2;
933
+ var _this2;
993
934
 
994
- _classCallCheck(this, Consumer);
995
-
996
- for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
935
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
997
936
  args[_key2] = arguments[_key2];
998
937
  }
999
938
 
1000
- return _ret2 = (_temp2 = (_this2 = _possibleConstructorReturn(this, _Component2.call.apply(_Component2, [this].concat(args))), _this2), _this2.state = {
939
+ _this2 = _Component2.call.apply(_Component2, [this].concat(args)) || this;
940
+
941
+ _defineProperty(_assertThisInitialized(_this2), "observedBits", void 0);
942
+
943
+ _defineProperty(_assertThisInitialized(_this2), "state", {
1001
944
  value: _this2.getValue()
1002
- }, _this2.onUpdate = function (newValue, changedBits) {
945
+ });
946
+
947
+ _defineProperty(_assertThisInitialized(_this2), "onUpdate", function (newValue, changedBits) {
1003
948
  var observedBits = _this2.observedBits | 0;
949
+
1004
950
  if ((observedBits & changedBits) !== 0) {
1005
- _this2.setState({ value: _this2.getValue() });
951
+ _this2.setState({
952
+ value: _this2.getValue()
953
+ });
1006
954
  }
1007
- }, _temp2), _possibleConstructorReturn(_this2, _ret2);
955
+ });
956
+
957
+ return _this2;
1008
958
  }
1009
959
 
1010
- Consumer.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
1011
- var observedBits = nextProps.observedBits;
960
+ var _proto2 = Consumer.prototype;
1012
961
 
962
+ _proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
963
+ var observedBits = nextProps.observedBits;
1013
964
  this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default
1014
965
  : observedBits;
1015
966
  };
1016
967
 
1017
- Consumer.prototype.componentDidMount = function componentDidMount() {
968
+ _proto2.componentDidMount = function componentDidMount() {
1018
969
  if (this.context[contextProp]) {
1019
970
  this.context[contextProp].on(this.onUpdate);
1020
971
  }
1021
- var observedBits = this.props.observedBits;
1022
972
 
973
+ var observedBits = this.props.observedBits;
1023
974
  this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT // Subscribe to all changes by default
1024
975
  : observedBits;
1025
976
  };
1026
977
 
1027
- Consumer.prototype.componentWillUnmount = function componentWillUnmount() {
978
+ _proto2.componentWillUnmount = function componentWillUnmount() {
1028
979
  if (this.context[contextProp]) {
1029
980
  this.context[contextProp].off(this.onUpdate);
1030
981
  }
1031
982
  };
1032
983
 
1033
- Consumer.prototype.getValue = function getValue() {
984
+ _proto2.getValue = function getValue() {
1034
985
  if (this.context[contextProp]) {
1035
986
  return this.context[contextProp].get();
1036
987
  } else {
@@ -1038,15 +989,14 @@
1038
989
  }
1039
990
  };
1040
991
 
1041
- Consumer.prototype.render = function render() {
992
+ _proto2.render = function render() {
1042
993
  return onlyChild(this.props.children)(this.state.value);
1043
994
  };
1044
995
 
1045
996
  return Consumer;
1046
997
  }(React.Component);
1047
998
 
1048
- Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = _propTypes2.default.object, _Consumer$contextType);
1049
-
999
+ _defineProperty(Consumer, "contextTypes", (_defineProperty3 = {}, _defineProperty3[contextProp] = propTypes.object, _defineProperty3));
1050
1000
 
1051
1001
  return {
1052
1002
  Provider: Provider,
@@ -1054,33 +1004,9 @@
1054
1004
  };
1055
1005
  }
1056
1006
 
1057
- exports.default = createReactContext;
1058
- module.exports = exports['default'];
1059
- });
1060
-
1061
- unwrapExports(implementation);
1062
-
1063
- var lib = createCommonjsModule(function (module, exports) {
1064
-
1065
- exports.__esModule = true;
1066
-
1067
-
1068
-
1069
- var _react2 = _interopRequireDefault(React);
1070
-
1071
-
1072
-
1073
- var _implementation2 = _interopRequireDefault(implementation);
1074
-
1075
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1076
-
1077
- exports.default = _react2.default.createContext || _implementation2.default;
1078
- module.exports = exports['default'];
1079
- });
1007
+ var index = React__default.createContext || createReactContext;
1080
1008
 
1081
- var createContext = unwrapExports(lib);
1082
-
1083
- function _inheritsLoose(subClass, superClass) {
1009
+ function _inheritsLoose$1(subClass, superClass) {
1084
1010
  subClass.prototype = Object.create(superClass.prototype);
1085
1011
  subClass.prototype.constructor = subClass;
1086
1012
  subClass.__proto__ = superClass;
@@ -2332,15 +2258,14 @@
2332
2258
  var hoistNonReactStatics_cjs = hoistNonReactStatics;
2333
2259
 
2334
2260
  var createNamedContext = function createNamedContext(name) {
2335
- var context = createContext();
2336
- context.Provider.displayName = name + ".Provider";
2337
- context.Consumer.displayName = name + ".Consumer";
2261
+ var context = index();
2262
+ context.displayName = name;
2338
2263
  return context;
2339
2264
  };
2340
2265
 
2341
2266
  var context =
2342
2267
  /*#__PURE__*/
2343
- createNamedContext('Router');
2268
+ createNamedContext("Router");
2344
2269
  /**
2345
2270
  * The public API for putting history on context.
2346
2271
  */
@@ -2348,7 +2273,7 @@
2348
2273
  var Router =
2349
2274
  /*#__PURE__*/
2350
2275
  function (_React$Component) {
2351
- _inheritsLoose(Router, _React$Component);
2276
+ _inheritsLoose$1(Router, _React$Component);
2352
2277
 
2353
2278
  Router.computeRootMatch = function computeRootMatch(pathname) {
2354
2279
  return {
@@ -2406,7 +2331,7 @@
2406
2331
  };
2407
2332
 
2408
2333
  _proto.render = function render() {
2409
- return React.createElement(context.Provider, {
2334
+ return React__default.createElement(context.Provider, {
2410
2335
  children: this.props.children || null,
2411
2336
  value: {
2412
2337
  history: this.props.history,
@@ -2418,7 +2343,7 @@
2418
2343
  };
2419
2344
 
2420
2345
  return Router;
2421
- }(React.Component);
2346
+ }(React__default.Component);
2422
2347
 
2423
2348
  {
2424
2349
  Router.propTypes = {
@@ -2439,7 +2364,7 @@
2439
2364
  var MemoryRouter =
2440
2365
  /*#__PURE__*/
2441
2366
  function (_React$Component) {
2442
- _inheritsLoose(MemoryRouter, _React$Component);
2367
+ _inheritsLoose$1(MemoryRouter, _React$Component);
2443
2368
 
2444
2369
  function MemoryRouter() {
2445
2370
  var _this;
@@ -2456,14 +2381,14 @@
2456
2381
  var _proto = MemoryRouter.prototype;
2457
2382
 
2458
2383
  _proto.render = function render() {
2459
- return React.createElement(Router, {
2384
+ return React__default.createElement(Router, {
2460
2385
  history: this.history,
2461
2386
  children: this.props.children
2462
2387
  });
2463
2388
  };
2464
2389
 
2465
2390
  return MemoryRouter;
2466
- }(React.Component);
2391
+ }(React__default.Component);
2467
2392
 
2468
2393
  {
2469
2394
  MemoryRouter.propTypes = {
@@ -2482,7 +2407,7 @@
2482
2407
  var Lifecycle =
2483
2408
  /*#__PURE__*/
2484
2409
  function (_React$Component) {
2485
- _inheritsLoose(Lifecycle, _React$Component);
2410
+ _inheritsLoose$1(Lifecycle, _React$Component);
2486
2411
 
2487
2412
  function Lifecycle() {
2488
2413
  return _React$Component.apply(this, arguments) || this;
@@ -2507,7 +2432,7 @@
2507
2432
  };
2508
2433
 
2509
2434
  return Lifecycle;
2510
- }(React.Component);
2435
+ }(React__default.Component);
2511
2436
  /**
2512
2437
  * The public API for prompting the user before navigating away from a screen.
2513
2438
  */
@@ -2517,11 +2442,11 @@
2517
2442
  var message = _ref.message,
2518
2443
  _ref$when = _ref.when,
2519
2444
  when = _ref$when === void 0 ? true : _ref$when;
2520
- return React.createElement(context.Consumer, null, function (context$$1) {
2445
+ return React__default.createElement(context.Consumer, null, function (context$$1) {
2521
2446
  !context$$1 ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
2522
2447
  if (!when || context$$1.staticContext) return null;
2523
2448
  var method = context$$1.history.block;
2524
- return React.createElement(Lifecycle, {
2449
+ return React__default.createElement(Lifecycle, {
2525
2450
  onMount: function onMount(self) {
2526
2451
  self.release = method(message);
2527
2452
  },
@@ -2590,7 +2515,7 @@
2590
2515
  to = _ref.to,
2591
2516
  _ref$push = _ref.push,
2592
2517
  push = _ref$push === void 0 ? false : _ref$push;
2593
- return React.createElement(context.Consumer, null, function (context$$1) {
2518
+ return React__default.createElement(context.Consumer, null, function (context$$1) {
2594
2519
  !context$$1 ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
2595
2520
  var history = context$$1.history,
2596
2521
  staticContext = context$$1.staticContext;
@@ -2605,12 +2530,16 @@
2605
2530
  return null;
2606
2531
  }
2607
2532
 
2608
- return React.createElement(Lifecycle, {
2533
+ return React__default.createElement(Lifecycle, {
2609
2534
  onMount: function onMount() {
2610
2535
  method(location);
2611
2536
  },
2612
2537
  onUpdate: function onUpdate(self, prevProps) {
2613
- if (!locationsAreEqual(prevProps.to, location)) {
2538
+ var prevLocation = createLocation(prevProps.to);
2539
+
2540
+ if (!locationsAreEqual(prevLocation, _extends({}, location, {
2541
+ key: prevLocation.key
2542
+ }))) {
2614
2543
  method(location);
2615
2544
  }
2616
2545
  },
@@ -2672,6 +2601,7 @@
2672
2601
  sensitive = _options$sensitive === void 0 ? false : _options$sensitive;
2673
2602
  var paths = [].concat(path);
2674
2603
  return paths.reduce(function (matched, path) {
2604
+ if (!path) return null;
2675
2605
  if (matched) return matched;
2676
2606
 
2677
2607
  var _compilePath = compilePath$1(path, {
@@ -2695,8 +2625,8 @@
2695
2625
  // the matched portion of the URL
2696
2626
  isExact: isExact,
2697
2627
  // whether or not we matched exactly
2698
- params: keys.reduce(function (memo, key, index) {
2699
- memo[key.name] = values[index];
2628
+ params: keys.reduce(function (memo, key, index$$1) {
2629
+ memo[key.name] = values[index$$1];
2700
2630
  return memo;
2701
2631
  }, {})
2702
2632
  };
@@ -2704,7 +2634,7 @@
2704
2634
  }
2705
2635
 
2706
2636
  function isEmptyChildren(children) {
2707
- return React.Children.count(children) === 0;
2637
+ return React__default.Children.count(children) === 0;
2708
2638
  }
2709
2639
  /**
2710
2640
  * The public API for matching a single path and rendering.
@@ -2714,7 +2644,7 @@
2714
2644
  var Route =
2715
2645
  /*#__PURE__*/
2716
2646
  function (_React$Component) {
2717
- _inheritsLoose(Route, _React$Component);
2647
+ _inheritsLoose$1(Route, _React$Component);
2718
2648
 
2719
2649
  function Route() {
2720
2650
  return _React$Component.apply(this, arguments) || this;
@@ -2725,7 +2655,7 @@
2725
2655
  _proto.render = function render() {
2726
2656
  var _this = this;
2727
2657
 
2728
- return React.createElement(context.Consumer, null, function (context$$1) {
2658
+ return React__default.createElement(context.Consumer, null, function (context$$1) {
2729
2659
  !context$$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
2730
2660
  var location = _this.props.location || context$$1.location;
2731
2661
  var match = _this.props.computedMatch ? _this.props.computedMatch // <Switch> already computed the match for us
@@ -2759,14 +2689,14 @@
2759
2689
  }
2760
2690
  }
2761
2691
 
2762
- return React.createElement(context.Provider, {
2692
+ return React__default.createElement(context.Provider, {
2763
2693
  value: props
2764
- }, children && !isEmptyChildren(children) ? children : props.match ? component ? React.createElement(component, props) : render ? render(props) : null : null);
2694
+ }, children && !isEmptyChildren(children) ? children : props.match ? component ? React__default.createElement(component, props) : render ? render(props) : null : null);
2765
2695
  });
2766
2696
  };
2767
2697
 
2768
2698
  return Route;
2769
- }(React.Component);
2699
+ }(React__default.Component);
2770
2700
 
2771
2701
  {
2772
2702
  Route.propTypes = {
@@ -2838,7 +2768,7 @@
2838
2768
  var StaticRouter =
2839
2769
  /*#__PURE__*/
2840
2770
  function (_React$Component) {
2841
- _inheritsLoose(StaticRouter, _React$Component);
2771
+ _inheritsLoose$1(StaticRouter, _React$Component);
2842
2772
 
2843
2773
  function StaticRouter() {
2844
2774
  var _this;
@@ -2874,7 +2804,8 @@
2874
2804
  var _this$props = this.props,
2875
2805
  _this$props$basename = _this$props.basename,
2876
2806
  basename = _this$props$basename === void 0 ? "" : _this$props$basename,
2877
- context = _this$props.context;
2807
+ _this$props$context = _this$props.context,
2808
+ context = _this$props$context === void 0 ? {} : _this$props$context;
2878
2809
  context.action = action;
2879
2810
  context.location = addBasename(basename, createLocation(location));
2880
2811
  context.url = createURL(context.location);
@@ -2904,14 +2835,14 @@
2904
2835
  listen: this.handleListen,
2905
2836
  block: this.handleBlock
2906
2837
  };
2907
- return React.createElement(Router, _extends({}, rest, {
2838
+ return React__default.createElement(Router, _extends({}, rest, {
2908
2839
  history: history,
2909
2840
  staticContext: context
2910
2841
  }));
2911
2842
  };
2912
2843
 
2913
2844
  return StaticRouter;
2914
- }(React.Component);
2845
+ }(React__default.Component);
2915
2846
 
2916
2847
  {
2917
2848
  StaticRouter.propTypes = {
@@ -2932,7 +2863,7 @@
2932
2863
  var Switch =
2933
2864
  /*#__PURE__*/
2934
2865
  function (_React$Component) {
2935
- _inheritsLoose(Switch, _React$Component);
2866
+ _inheritsLoose$1(Switch, _React$Component);
2936
2867
 
2937
2868
  function Switch() {
2938
2869
  return _React$Component.apply(this, arguments) || this;
@@ -2943,7 +2874,7 @@
2943
2874
  _proto.render = function render() {
2944
2875
  var _this = this;
2945
2876
 
2946
- return React.createElement(context.Consumer, null, function (context$$1) {
2877
+ return React__default.createElement(context.Consumer, null, function (context$$1) {
2947
2878
  !context$$1 ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
2948
2879
  var location = _this.props.location || context$$1.location;
2949
2880
  var element, match; // We use React.Children.forEach instead of React.Children.toArray().find()
@@ -2951,8 +2882,8 @@
2951
2882
  // to trigger an unmount/remount for two <Route>s that render the same
2952
2883
  // component at different URLs.
2953
2884
 
2954
- React.Children.forEach(_this.props.children, function (child) {
2955
- if (match == null && React.isValidElement(child)) {
2885
+ React__default.Children.forEach(_this.props.children, function (child) {
2886
+ if (match == null && React__default.isValidElement(child)) {
2956
2887
  element = child;
2957
2888
  var path = child.props.path || child.props.from;
2958
2889
  match = path ? matchPath(location.pathname, _extends({}, child.props, {
@@ -2960,7 +2891,7 @@
2960
2891
  })) : context$$1.match;
2961
2892
  }
2962
2893
  });
2963
- return match ? React.cloneElement(element, {
2894
+ return match ? React__default.cloneElement(element, {
2964
2895
  location: location,
2965
2896
  computedMatch: match
2966
2897
  }) : null;
@@ -2968,7 +2899,7 @@
2968
2899
  };
2969
2900
 
2970
2901
  return Switch;
2971
- }(React.Component);
2902
+ }(React__default.Component);
2972
2903
 
2973
2904
  {
2974
2905
  Switch.propTypes = {
@@ -2987,25 +2918,26 @@
2987
2918
 
2988
2919
 
2989
2920
  function withRouter(Component) {
2921
+ var displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
2922
+
2990
2923
  var C = function C(props) {
2991
2924
  var wrappedComponentRef = props.wrappedComponentRef,
2992
2925
  remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
2993
2926
 
2994
- return React.createElement(Route, {
2995
- children: function children(routeComponentProps) {
2996
- return React.createElement(Component, _extends({}, remainingProps, routeComponentProps, {
2997
- ref: wrappedComponentRef
2998
- }));
2999
- }
2927
+ return React__default.createElement(context.Consumer, null, function (context$$1) {
2928
+ !context$$1 ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : void 0;
2929
+ return React__default.createElement(Component, _extends({}, remainingProps, context$$1, {
2930
+ ref: wrappedComponentRef
2931
+ }));
3000
2932
  });
3001
2933
  };
3002
2934
 
3003
- C.displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
2935
+ C.displayName = displayName;
3004
2936
  C.WrappedComponent = Component;
3005
2937
 
3006
2938
  {
3007
2939
  C.propTypes = {
3008
- wrappedComponentRef: propTypes.func
2940
+ wrappedComponentRef: propTypes.oneOfType([propTypes.string, propTypes.func, propTypes.object])
3009
2941
  };
3010
2942
  }
3011
2943
 
@@ -3034,7 +2966,7 @@
3034
2966
  }
3035
2967
  }
3036
2968
 
3037
- function _inheritsLoose$1(subClass, superClass) {
2969
+ function _inheritsLoose$2(subClass, superClass) {
3038
2970
  subClass.prototype = Object.create(superClass.prototype);
3039
2971
  subClass.prototype.constructor = subClass;
3040
2972
  subClass.__proto__ = superClass;
@@ -4039,13 +3971,13 @@
4039
3971
 
4040
3972
  var ReactPropTypesSecret_1$1 = ReactPropTypesSecret$2;
4041
3973
 
4042
- var printWarning$3 = function() {};
3974
+ var printWarning$2 = function() {};
4043
3975
 
4044
3976
  {
4045
3977
  var ReactPropTypesSecret$3 = ReactPropTypesSecret_1$1;
4046
3978
  var loggedTypeFailures$1 = {};
4047
3979
 
4048
- printWarning$3 = function(text) {
3980
+ printWarning$2 = function(text) {
4049
3981
  var message = 'Warning: ' + text;
4050
3982
  if (typeof console !== 'undefined') {
4051
3983
  console.error(message);
@@ -4094,7 +4026,7 @@
4094
4026
  error = ex;
4095
4027
  }
4096
4028
  if (error && !(error instanceof Error)) {
4097
- printWarning$3(
4029
+ printWarning$2(
4098
4030
  (componentName || 'React class') + ': type specification of ' +
4099
4031
  location + ' `' + typeSpecName + '` is invalid; the type checker ' +
4100
4032
  'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
@@ -4111,7 +4043,7 @@
4111
4043
 
4112
4044
  var stack = getStack ? getStack() : '';
4113
4045
 
4114
- printWarning$3(
4046
+ printWarning$2(
4115
4047
  'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
4116
4048
  );
4117
4049
  }
@@ -4122,10 +4054,10 @@
4122
4054
 
4123
4055
  var checkPropTypes_1$1 = checkPropTypes$1;
4124
4056
 
4125
- var printWarning$4 = function() {};
4057
+ var printWarning$3 = function() {};
4126
4058
 
4127
4059
  {
4128
- printWarning$4 = function(text) {
4060
+ printWarning$3 = function(text) {
4129
4061
  var message = 'Warning: ' + text;
4130
4062
  if (typeof console !== 'undefined') {
4131
4063
  console.error(message);
@@ -4300,7 +4232,7 @@
4300
4232
  // Avoid spamming the console because they are often not actionable except for lib authors
4301
4233
  manualPropTypeWarningCount < 3
4302
4234
  ) {
4303
- printWarning$4(
4235
+ printWarning$3(
4304
4236
  'You are manually calling a React.PropTypes validation ' +
4305
4237
  'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
4306
4238
  'and will throw in the standalone `prop-types` package. ' +
@@ -4399,7 +4331,7 @@
4399
4331
 
4400
4332
  function createEnumTypeChecker(expectedValues) {
4401
4333
  if (!Array.isArray(expectedValues)) {
4402
- printWarning$4('Invalid argument supplied to oneOf, expected an instance of array.');
4334
+ printWarning$3('Invalid argument supplied to oneOf, expected an instance of array.');
4403
4335
  return emptyFunctionThatReturnsNull$1;
4404
4336
  }
4405
4337
 
@@ -4442,14 +4374,14 @@
4442
4374
 
4443
4375
  function createUnionTypeChecker(arrayOfTypeCheckers) {
4444
4376
  if (!Array.isArray(arrayOfTypeCheckers)) {
4445
- printWarning$4('Invalid argument supplied to oneOfType, expected an instance of array.');
4377
+ printWarning$3('Invalid argument supplied to oneOfType, expected an instance of array.');
4446
4378
  return emptyFunctionThatReturnsNull$1;
4447
4379
  }
4448
4380
 
4449
4381
  for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
4450
4382
  var checker = arrayOfTypeCheckers[i];
4451
4383
  if (typeof checker !== 'function') {
4452
- printWarning$4(
4384
+ printWarning$3(
4453
4385
  'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
4454
4386
  'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
4455
4387
  );
@@ -4698,7 +4630,7 @@
4698
4630
  var BrowserRouter =
4699
4631
  /*#__PURE__*/
4700
4632
  function (_React$Component) {
4701
- _inheritsLoose$1(BrowserRouter, _React$Component);
4633
+ _inheritsLoose$2(BrowserRouter, _React$Component);
4702
4634
 
4703
4635
  function BrowserRouter() {
4704
4636
  var _this;
@@ -4715,14 +4647,14 @@
4715
4647
  var _proto = BrowserRouter.prototype;
4716
4648
 
4717
4649
  _proto.render = function render() {
4718
- return React.createElement(Router, {
4650
+ return React__default.createElement(Router, {
4719
4651
  history: this.history,
4720
4652
  children: this.props.children
4721
4653
  });
4722
4654
  };
4723
4655
 
4724
4656
  return BrowserRouter;
4725
- }(React.Component);
4657
+ }(React__default.Component);
4726
4658
 
4727
4659
  {
4728
4660
  BrowserRouter.propTypes = {
@@ -4745,7 +4677,7 @@
4745
4677
  var HashRouter =
4746
4678
  /*#__PURE__*/
4747
4679
  function (_React$Component) {
4748
- _inheritsLoose$1(HashRouter, _React$Component);
4680
+ _inheritsLoose$2(HashRouter, _React$Component);
4749
4681
 
4750
4682
  function HashRouter() {
4751
4683
  var _this;
@@ -4762,14 +4694,14 @@
4762
4694
  var _proto = HashRouter.prototype;
4763
4695
 
4764
4696
  _proto.render = function render() {
4765
- return React.createElement(Router, {
4697
+ return React__default.createElement(Router, {
4766
4698
  history: this.history,
4767
4699
  children: this.props.children
4768
4700
  });
4769
4701
  };
4770
4702
 
4771
4703
  return HashRouter;
4772
- }(React.Component);
4704
+ }(React__default.Component);
4773
4705
 
4774
4706
  {
4775
4707
  HashRouter.propTypes = {
@@ -4810,7 +4742,7 @@
4810
4742
  var Link =
4811
4743
  /*#__PURE__*/
4812
4744
  function (_React$Component) {
4813
- _inheritsLoose$1(Link, _React$Component);
4745
+ _inheritsLoose$2(Link, _React$Component);
4814
4746
 
4815
4747
  function Link() {
4816
4748
  return _React$Component.apply(this, arguments) || this;
@@ -4819,7 +4751,12 @@
4819
4751
  var _proto = Link.prototype;
4820
4752
 
4821
4753
  _proto.handleClick = function handleClick(event, history) {
4822
- if (this.props.onClick) this.props.onClick(event);
4754
+ try {
4755
+ if (this.props.onClick) this.props.onClick(event);
4756
+ } catch (ex) {
4757
+ event.preventDefault();
4758
+ throw ex;
4759
+ }
4823
4760
 
4824
4761
  if (!event.defaultPrevented && // onClick prevented default
4825
4762
  event.button === 0 && ( // ignore everything but left clicks
@@ -4842,11 +4779,11 @@
4842
4779
  rest = _objectWithoutPropertiesLoose$1(_this$props, ["innerRef", "replace", "to"]); // eslint-disable-line no-unused-vars
4843
4780
 
4844
4781
 
4845
- return React.createElement(context.Consumer, null, function (context$$1) {
4782
+ return React__default.createElement(context.Consumer, null, function (context$$1) {
4846
4783
  !context$$1 ? invariant$1(false, "You should not use <Link> outside a <Router>") : void 0;
4847
4784
  var location = typeof to === "string" ? createLocation$1(to, null, null, context$$1.location) : to;
4848
4785
  var href = location ? context$$1.history.createHref(location) : "";
4849
- return React.createElement("a", _extends$1({}, rest, {
4786
+ return React__default.createElement("a", _extends$1({}, rest, {
4850
4787
  onClick: function onClick(event) {
4851
4788
  return _this.handleClick(event, context$$1.history);
4852
4789
  },
@@ -4857,7 +4794,7 @@
4857
4794
  };
4858
4795
 
4859
4796
  return Link;
4860
- }(React.Component);
4797
+ }(React__default.Component);
4861
4798
 
4862
4799
  {
4863
4800
  var toType = propTypes$1.oneOfType([propTypes$1.string, propTypes$1.object]);
@@ -4896,7 +4833,7 @@
4896
4833
  classNameProp = _ref.className,
4897
4834
  exact = _ref.exact,
4898
4835
  isActiveProp = _ref.isActive,
4899
- location = _ref.location,
4836
+ locationProp = _ref.location,
4900
4837
  strict = _ref.strict,
4901
4838
  styleProp = _ref.style,
4902
4839
  to = _ref.to,
@@ -4905,24 +4842,23 @@
4905
4842
  var path = typeof to === "object" ? to.pathname : to; // Regex taken from: https://github.com/pillarjs/path-to-regexp/blob/master/index.js#L202
4906
4843
 
4907
4844
  var escapedPath = path && path.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
4908
- return React.createElement(Route, {
4909
- path: escapedPath,
4910
- exact: exact,
4911
- strict: strict,
4912
- location: location,
4913
- children: function children(_ref2) {
4914
- var location = _ref2.location,
4915
- match = _ref2.match;
4916
- var isActive = !!(isActiveProp ? isActiveProp(match, location) : match);
4917
- var className = isActive ? joinClassnames(classNameProp, activeClassName) : classNameProp;
4918
- var style = isActive ? _extends$1({}, styleProp, activeStyle) : styleProp;
4919
- return React.createElement(Link, _extends$1({
4920
- "aria-current": isActive && ariaCurrent || null,
4921
- className: className,
4922
- style: style,
4923
- to: to
4924
- }, rest));
4925
- }
4845
+ return React__default.createElement(context.Consumer, null, function (context$$1) {
4846
+ !context$$1 ? invariant$1(false, "You should not use <NavLink> outside a <Router>") : void 0;
4847
+ var pathToMatch = locationProp ? locationProp.pathname : context$$1.location.pathname;
4848
+ var match = escapedPath ? matchPath(pathToMatch, {
4849
+ path: escapedPath,
4850
+ exact: exact,
4851
+ strict: strict
4852
+ }) : null;
4853
+ var isActive = !!(isActiveProp ? isActiveProp(match, context$$1.location) : match);
4854
+ var className = isActive ? joinClassnames(classNameProp, activeClassName) : classNameProp;
4855
+ var style = isActive ? _extends$1({}, styleProp, activeStyle) : styleProp;
4856
+ return React__default.createElement(Link, _extends$1({
4857
+ "aria-current": isActive && ariaCurrent || null,
4858
+ className: className,
4859
+ style: style,
4860
+ to: to
4861
+ }, rest));
4926
4862
  });
4927
4863
  }
4928
4864
 
@@ -4933,10 +4869,10 @@
4933
4869
  activeClassName: propTypes$1.string,
4934
4870
  activeStyle: propTypes$1.object,
4935
4871
  className: propTypes$1.string,
4936
- exact: Route.propTypes.exact,
4872
+ exact: propTypes$1.bool,
4937
4873
  isActive: propTypes$1.func,
4938
4874
  location: propTypes$1.object,
4939
- strict: Route.propTypes.strict,
4875
+ strict: propTypes$1.bool,
4940
4876
  style: propTypes$1.object
4941
4877
  });
4942
4878
  }