react-router-dom 5.1.2 → 5.2.0

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.
package/modules/index.js CHANGED
@@ -1,6 +1,21 @@
1
- export * from "react-router";
1
+ export {
2
+ MemoryRouter,
3
+ Prompt,
4
+ Redirect,
5
+ Route,
6
+ Router,
7
+ StaticRouter,
8
+ Switch,
9
+ generatePath,
10
+ matchPath,
11
+ withRouter,
12
+ useHistory,
13
+ useLocation,
14
+ useParams,
15
+ useRouteMatch
16
+ } from "react-router";
2
17
 
3
- export { default as BrowserRouter } from "./BrowserRouter";
4
- export { default as HashRouter } from "./HashRouter";
5
- export { default as Link } from "./Link";
6
- export { default as NavLink } from "./NavLink";
18
+ export { default as BrowserRouter } from "./BrowserRouter.js";
19
+ export { default as HashRouter } from "./HashRouter.js";
20
+ export { default as Link } from "./Link.js";
21
+ export { default as NavLink } from "./NavLink.js";
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "react-router-dom",
3
- "version": "5.1.2",
3
+ "version": "5.2.0",
4
4
  "description": "DOM bindings for React Router",
5
5
  "repository": "ReactTraining/react-router",
6
6
  "license": "MIT",
7
- "authors": [
8
- "Michael Jackson",
9
- "Ryan Florence"
10
- ],
7
+ "author": "React Training <hello@reacttraining.com>",
11
8
  "files": [
12
9
  "BrowserRouter.js",
13
10
  "HashRouter.js",
@@ -37,8 +34,7 @@
37
34
  "sideEffects": false,
38
35
  "scripts": {
39
36
  "build": "rollup -c",
40
- "lint": "eslint modules",
41
- "test": "jest"
37
+ "lint": "eslint modules"
42
38
  },
43
39
  "peerDependencies": {
44
40
  "react": ">=15"
@@ -48,7 +44,7 @@
48
44
  "history": "^4.9.0",
49
45
  "loose-envify": "^1.3.1",
50
46
  "prop-types": "^15.6.2",
51
- "react-router": "5.1.2",
47
+ "react-router": "5.2.0",
52
48
  "tiny-invariant": "^1.0.2",
53
49
  "tiny-warning": "^1.0.0"
54
50
  },
@@ -65,5 +61,5 @@
65
61
  "history",
66
62
  "link"
67
63
  ],
68
- "gitHead": "f31bb27aa61dd4cb1c3cd9aa78133f739e2e9bb9"
64
+ "gitHead": "21a62e55c0d6196002bd4ab5b3350514976928cf"
69
65
  }
@@ -12,8 +12,6 @@
12
12
  subClass.__proto__ = superClass;
13
13
  }
14
14
 
15
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
16
-
17
15
  function unwrapExports (x) {
18
16
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
19
17
  }
@@ -2168,15 +2166,13 @@
2168
2166
  subClass.__proto__ = superClass;
2169
2167
  }
2170
2168
 
2171
- var inheritsLoose = _inheritsLoose$1;
2172
-
2173
- var key = '__global_unique_id__';
2169
+ var MAX_SIGNED_31_BIT_INT = 1073741823;
2170
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
2174
2171
 
2175
- var gud = function() {
2172
+ function getUniqueId() {
2173
+ var key = '__global_unique_id__';
2176
2174
  return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
2177
- };
2178
-
2179
- var MAX_SIGNED_31_BIT_INT = 1073741823;
2175
+ }
2180
2176
 
2181
2177
  function objectIs(x, y) {
2182
2178
  if (x === y) {
@@ -2216,12 +2212,10 @@
2216
2212
  function createReactContext(defaultValue, calculateChangedBits) {
2217
2213
  var _Provider$childContex, _Consumer$contextType;
2218
2214
 
2219
- var contextProp = '__create-react-context-' + gud() + '__';
2215
+ var contextProp = '__create-react-context-' + getUniqueId() + '__';
2220
2216
 
2221
- var Provider =
2222
- /*#__PURE__*/
2223
- function (_Component) {
2224
- inheritsLoose(Provider, _Component);
2217
+ var Provider = /*#__PURE__*/function (_Component) {
2218
+ _inheritsLoose$1(Provider, _Component);
2225
2219
 
2226
2220
  function Provider() {
2227
2221
  var _this;
@@ -2272,10 +2266,8 @@
2272
2266
 
2273
2267
  Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = propTypes.object.isRequired, _Provider$childContex);
2274
2268
 
2275
- var Consumer =
2276
- /*#__PURE__*/
2277
- function (_Component2) {
2278
- inheritsLoose(Consumer, _Component2);
2269
+ var Consumer = /*#__PURE__*/function (_Component2) {
2270
+ _inheritsLoose$1(Consumer, _Component2);
2279
2271
 
2280
2272
  function Consumer() {
2281
2273
  var _this2;
@@ -2900,9 +2892,19 @@
2900
2892
  return context;
2901
2893
  };
2902
2894
 
2895
+ var historyContext =
2896
+ /*#__PURE__*/
2897
+ createNamedContext("Router-History"); // TODO: Replace with React.createContext once we can assume React 16+
2898
+
2899
+ var createNamedContext$1 = function createNamedContext(name) {
2900
+ var context = index();
2901
+ context.displayName = name;
2902
+ return context;
2903
+ };
2904
+
2903
2905
  var context =
2904
2906
  /*#__PURE__*/
2905
- createNamedContext("Router");
2907
+ createNamedContext$1("Router");
2906
2908
  /**
2907
2909
  * The public API for putting history on context.
2908
2910
  */
@@ -2969,14 +2971,16 @@
2969
2971
 
2970
2972
  _proto.render = function render() {
2971
2973
  return React__default.createElement(context.Provider, {
2972
- children: this.props.children || null,
2973
2974
  value: {
2974
2975
  history: this.props.history,
2975
2976
  location: this.state.location,
2976
2977
  match: Router.computeRootMatch(this.state.location.pathname),
2977
2978
  staticContext: this.props.staticContext
2978
2979
  }
2979
- });
2980
+ }, React__default.createElement(historyContext.Provider, {
2981
+ children: this.props.children || null,
2982
+ value: this.props.history
2983
+ }));
2980
2984
  };
2981
2985
 
2982
2986
  return Router;
@@ -2990,7 +2994,7 @@
2990
2994
  };
2991
2995
 
2992
2996
  Router.prototype.componentDidUpdate = function (prevProps) {
2993
- warning(prevProps.history === this.props.history, "You cannot change <Router history>") ;
2997
+ warning(prevProps.history === this.props.history, "You cannot change <Router history>") ;
2994
2998
  };
2995
2999
  }
2996
3000
  /**
@@ -3037,7 +3041,7 @@
3037
3041
  };
3038
3042
 
3039
3043
  MemoryRouter.prototype.componentDidMount = function () {
3040
- warning(!this.props.history, "<MemoryRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { MemoryRouter as Router }`.") ;
3044
+ warning(!this.props.history, "<MemoryRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { MemoryRouter as Router }`.") ;
3041
3045
  };
3042
3046
  }
3043
3047
 
@@ -3080,7 +3084,7 @@
3080
3084
  _ref$when = _ref.when,
3081
3085
  when = _ref$when === void 0 ? true : _ref$when;
3082
3086
  return React__default.createElement(context.Consumer, null, function (context) {
3083
- !context ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
3087
+ !context ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
3084
3088
  if (!when || context.staticContext) return null;
3085
3089
  var method = context.history.block;
3086
3090
  return React__default.createElement(Lifecycle, {
@@ -3153,7 +3157,7 @@
3153
3157
  _ref$push = _ref.push,
3154
3158
  push = _ref$push === void 0 ? false : _ref$push;
3155
3159
  return React__default.createElement(context.Consumer, null, function (context) {
3156
- !context ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
3160
+ !context ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
3157
3161
  var history = context.history,
3158
3162
  staticContext = context.staticContext;
3159
3163
  var method = push ? history.push : history.replace;
@@ -3279,7 +3283,7 @@
3279
3283
 
3280
3284
  function evalChildrenDev(children, props, path) {
3281
3285
  var value = children(props);
3282
- 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`") ;
3286
+ 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`") ;
3283
3287
  return value || null;
3284
3288
  }
3285
3289
  /**
@@ -3302,7 +3306,7 @@
3302
3306
  var _this = this;
3303
3307
 
3304
3308
  return React__default.createElement(context.Consumer, null, function (context$1) {
3305
- !context$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
3309
+ !context$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
3306
3310
  var location = _this.props.location || context$1.location;
3307
3311
  var match = _this.props.computedMatch ? _this.props.computedMatch // <Switch> already computed the match for us
3308
3312
  : _this.props.path ? matchPath(location.pathname, _this.props) : context$1.match;
@@ -3348,14 +3352,14 @@
3348
3352
  };
3349
3353
 
3350
3354
  Route.prototype.componentDidMount = function () {
3351
- 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") ;
3352
- 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") ;
3353
- 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") ;
3355
+ 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") ;
3356
+ 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") ;
3357
+ 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") ;
3354
3358
  };
3355
3359
 
3356
3360
  Route.prototype.componentDidUpdate = function (prevProps) {
3357
- 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.') ;
3358
- 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.') ;
3361
+ 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.') ;
3362
+ 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.') ;
3359
3363
  };
3360
3364
  }
3361
3365
 
@@ -3385,7 +3389,7 @@
3385
3389
 
3386
3390
  function staticHandler(methodName) {
3387
3391
  return function () {
3388
- invariant(false, "You cannot %s with <StaticRouter>") ;
3392
+ invariant(false, "You cannot %s with <StaticRouter>") ;
3389
3393
  };
3390
3394
  }
3391
3395
 
@@ -3485,7 +3489,7 @@
3485
3489
  };
3486
3490
 
3487
3491
  StaticRouter.prototype.componentDidMount = function () {
3488
- warning(!this.props.history, "<StaticRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { StaticRouter as Router }`.") ;
3492
+ warning(!this.props.history, "<StaticRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { StaticRouter as Router }`.") ;
3489
3493
  };
3490
3494
  }
3491
3495
  /**
@@ -3508,7 +3512,7 @@
3508
3512
  var _this = this;
3509
3513
 
3510
3514
  return React__default.createElement(context.Consumer, null, function (context) {
3511
- !context ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
3515
+ !context ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
3512
3516
  var location = _this.props.location || context.location;
3513
3517
  var element, match; // We use React.Children.forEach instead of React.Children.toArray().find()
3514
3518
  // here because toArray adds keys to all child elements and we do not want
@@ -3541,8 +3545,8 @@
3541
3545
  };
3542
3546
 
3543
3547
  Switch.prototype.componentDidUpdate = function (prevProps) {
3544
- 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.') ;
3545
- 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.') ;
3548
+ 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.') ;
3549
+ 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.') ;
3546
3550
  };
3547
3551
  }
3548
3552
  /**
@@ -3558,7 +3562,7 @@
3558
3562
  remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
3559
3563
 
3560
3564
  return React__default.createElement(context.Consumer, null, function (context) {
3561
- !context ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : void 0;
3565
+ !context ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : void 0;
3562
3566
  return React__default.createElement(Component, _extends({}, remainingProps, context, {
3563
3567
  ref: wrappedComponentRef
3564
3568
  }));
@@ -3581,15 +3585,15 @@
3581
3585
 
3582
3586
  function useHistory() {
3583
3587
  {
3584
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : void 0;
3588
+ !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : void 0;
3585
3589
  }
3586
3590
 
3587
- return useContext(context).history;
3591
+ return useContext(historyContext);
3588
3592
  }
3589
3593
 
3590
3594
  function useLocation() {
3591
3595
  {
3592
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useLocation()") : void 0;
3596
+ !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useLocation()") : void 0;
3593
3597
  }
3594
3598
 
3595
3599
  return useContext(context).location;
@@ -3597,7 +3601,7 @@
3597
3601
 
3598
3602
  function useParams() {
3599
3603
  {
3600
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useParams()") : void 0;
3604
+ !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useParams()") : void 0;
3601
3605
  }
3602
3606
 
3603
3607
  var match = useContext(context).match;
@@ -3606,31 +3610,33 @@
3606
3610
 
3607
3611
  function useRouteMatch(path) {
3608
3612
  {
3609
- !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useRouteMatch()") : void 0;
3613
+ !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useRouteMatch()") : void 0;
3610
3614
  }
3611
3615
 
3612
- return path ? matchPath(useLocation().pathname, path) : useContext(context).match;
3616
+ var location = useLocation();
3617
+ var match = useContext(context).match;
3618
+ return path ? matchPath(location.pathname, path) : match;
3613
3619
  }
3614
3620
 
3615
3621
  {
3616
3622
  if (typeof window !== "undefined") {
3617
3623
  var global$1 = window;
3618
- var key$1 = "__react_router_build__";
3624
+ var key = "__react_router_build__";
3619
3625
  var buildNames = {
3620
3626
  cjs: "CommonJS",
3621
3627
  esm: "ES modules",
3622
3628
  umd: "UMD"
3623
3629
  };
3624
3630
 
3625
- if (global$1[key$1] && global$1[key$1] !== "esm") {
3626
- var initialBuildName = buildNames[global$1[key$1]];
3631
+ if (global$1[key] && global$1[key] !== "esm") {
3632
+ var initialBuildName = buildNames[global$1[key]];
3627
3633
  var secondaryBuildName = buildNames["esm"]; // TODO: Add link to article that explains in detail how to avoid
3628
3634
  // loading 2 different builds.
3629
3635
 
3630
3636
  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.");
3631
3637
  }
3632
3638
 
3633
- global$1[key$1] = "esm";
3639
+ global$1[key] = "esm";
3634
3640
  }
3635
3641
  }
3636
3642
 
@@ -3782,6 +3788,8 @@
3782
3788
  } else {
3783
3789
  props.ref = innerRef;
3784
3790
  }
3791
+ /* eslint-disable-next-line jsx-a11y/anchor-has-content */
3792
+
3785
3793
 
3786
3794
  return React__default.createElement("a", props);
3787
3795
  });
@@ -3877,11 +3885,12 @@
3877
3885
  exact = _ref.exact,
3878
3886
  isActiveProp = _ref.isActive,
3879
3887
  locationProp = _ref.location,
3888
+ sensitive = _ref.sensitive,
3880
3889
  strict = _ref.strict,
3881
3890
  styleProp = _ref.style,
3882
3891
  to = _ref.to,
3883
3892
  innerRef = _ref.innerRef,
3884
- rest = _objectWithoutPropertiesLoose(_ref, ["aria-current", "activeClassName", "activeStyle", "className", "exact", "isActive", "location", "strict", "style", "to", "innerRef"]);
3893
+ rest = _objectWithoutPropertiesLoose(_ref, ["aria-current", "activeClassName", "activeStyle", "className", "exact", "isActive", "location", "sensitive", "strict", "style", "to", "innerRef"]);
3885
3894
 
3886
3895
  return React__default.createElement(context.Consumer, null, function (context) {
3887
3896
  !context ? invariant(false, "You should not use <NavLink> outside a <Router>") : void 0;
@@ -3893,6 +3902,7 @@
3893
3902
  var match = escapedPath ? matchPath(currentLocation.pathname, {
3894
3903
  path: escapedPath,
3895
3904
  exact: exact,
3905
+ sensitive: sensitive,
3896
3906
  strict: strict
3897
3907
  }) : null;
3898
3908
  var isActive = !!(isActiveProp ? isActiveProp(match, currentLocation) : match);
@@ -3928,6 +3938,7 @@
3928
3938
  exact: propTypes.bool,
3929
3939
  isActive: propTypes.func,
3930
3940
  location: propTypes.object,
3941
+ sensitive: propTypes.bool,
3931
3942
  strict: propTypes.bool,
3932
3943
  style: propTypes.object
3933
3944
  });
@@ -3944,7 +3955,6 @@
3944
3955
  exports.Router = Router;
3945
3956
  exports.StaticRouter = StaticRouter;
3946
3957
  exports.Switch = Switch;
3947
- exports.__RouterContext = context;
3948
3958
  exports.generatePath = generatePath;
3949
3959
  exports.matchPath = matchPath;
3950
3960
  exports.useHistory = useHistory;