react-router 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.
@@ -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
  }
@@ -1579,15 +1577,13 @@
1579
1577
  subClass.__proto__ = superClass;
1580
1578
  }
1581
1579
 
1582
- var inheritsLoose = _inheritsLoose$1;
1583
-
1584
- var key = '__global_unique_id__';
1580
+ var MAX_SIGNED_31_BIT_INT = 1073741823;
1581
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
1585
1582
 
1586
- var gud = function() {
1583
+ function getUniqueId() {
1584
+ var key = '__global_unique_id__';
1587
1585
  return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
1588
- };
1589
-
1590
- var MAX_SIGNED_31_BIT_INT = 1073741823;
1586
+ }
1591
1587
 
1592
1588
  function objectIs(x, y) {
1593
1589
  if (x === y) {
@@ -1627,12 +1623,10 @@
1627
1623
  function createReactContext(defaultValue, calculateChangedBits) {
1628
1624
  var _Provider$childContex, _Consumer$contextType;
1629
1625
 
1630
- var contextProp = '__create-react-context-' + gud() + '__';
1626
+ var contextProp = '__create-react-context-' + getUniqueId() + '__';
1631
1627
 
1632
- var Provider =
1633
- /*#__PURE__*/
1634
- function (_Component) {
1635
- inheritsLoose(Provider, _Component);
1628
+ var Provider = /*#__PURE__*/function (_Component) {
1629
+ _inheritsLoose$1(Provider, _Component);
1636
1630
 
1637
1631
  function Provider() {
1638
1632
  var _this;
@@ -1683,10 +1677,8 @@
1683
1677
 
1684
1678
  Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = propTypes.object.isRequired, _Provider$childContex);
1685
1679
 
1686
- var Consumer =
1687
- /*#__PURE__*/
1688
- function (_Component2) {
1689
- inheritsLoose(Consumer, _Component2);
1680
+ var Consumer = /*#__PURE__*/function (_Component2) {
1681
+ _inheritsLoose$1(Consumer, _Component2);
1690
1682
 
1691
1683
  function Consumer() {
1692
1684
  var _this2;
@@ -1763,9 +1755,21 @@
1763
1755
  return context;
1764
1756
  };
1765
1757
 
1758
+ var historyContext =
1759
+ /*#__PURE__*/
1760
+ createNamedContext("Router-History");
1761
+
1762
+ // TODO: Replace with React.createContext once we can assume React 16+
1763
+
1764
+ var createNamedContext$1 = function createNamedContext(name) {
1765
+ var context = index();
1766
+ context.displayName = name;
1767
+ return context;
1768
+ };
1769
+
1766
1770
  var context =
1767
1771
  /*#__PURE__*/
1768
- createNamedContext("Router");
1772
+ createNamedContext$1("Router");
1769
1773
 
1770
1774
  /**
1771
1775
  * The public API for putting history on context.
@@ -1833,14 +1837,16 @@
1833
1837
 
1834
1838
  _proto.render = function render() {
1835
1839
  return React__default.createElement(context.Provider, {
1836
- children: this.props.children || null,
1837
1840
  value: {
1838
1841
  history: this.props.history,
1839
1842
  location: this.state.location,
1840
1843
  match: Router.computeRootMatch(this.state.location.pathname),
1841
1844
  staticContext: this.props.staticContext
1842
1845
  }
1843
- });
1846
+ }, React__default.createElement(historyContext.Provider, {
1847
+ children: this.props.children || null,
1848
+ value: this.props.history
1849
+ }));
1844
1850
  };
1845
1851
 
1846
1852
  return Router;
@@ -2997,7 +3003,7 @@
2997
3003
  !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : void 0;
2998
3004
  }
2999
3005
 
3000
- return useContext(context).history;
3006
+ return useContext(historyContext);
3001
3007
  }
3002
3008
  function useLocation() {
3003
3009
  {
@@ -3019,28 +3025,30 @@
3019
3025
  !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useRouteMatch()") : void 0;
3020
3026
  }
3021
3027
 
3022
- return path ? matchPath(useLocation().pathname, path) : useContext(context).match;
3028
+ var location = useLocation();
3029
+ var match = useContext(context).match;
3030
+ return path ? matchPath(location.pathname, path) : match;
3023
3031
  }
3024
3032
 
3025
3033
  {
3026
3034
  if (typeof window !== "undefined") {
3027
3035
  var global$1 = window;
3028
- var key$1 = "__react_router_build__";
3036
+ var key = "__react_router_build__";
3029
3037
  var buildNames = {
3030
3038
  cjs: "CommonJS",
3031
3039
  esm: "ES modules",
3032
3040
  umd: "UMD"
3033
3041
  };
3034
3042
 
3035
- if (global$1[key$1] && global$1[key$1] !== "umd") {
3036
- var initialBuildName = buildNames[global$1[key$1]];
3043
+ if (global$1[key] && global$1[key] !== "umd") {
3044
+ var initialBuildName = buildNames[global$1[key]];
3037
3045
  var secondaryBuildName = buildNames["umd"]; // TODO: Add link to article that explains in detail how to avoid
3038
3046
  // loading 2 different builds.
3039
3047
 
3040
3048
  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.");
3041
3049
  }
3042
3050
 
3043
- global$1[key$1] = "umd";
3051
+ global$1[key] = "umd";
3044
3052
  }
3045
3053
  }
3046
3054
 
@@ -3051,6 +3059,7 @@
3051
3059
  exports.Router = Router;
3052
3060
  exports.StaticRouter = StaticRouter;
3053
3061
  exports.Switch = Switch;
3062
+ exports.__HistoryContext = historyContext;
3054
3063
  exports.__RouterContext = context;
3055
3064
  exports.generatePath = generatePath;
3056
3065
  exports.matchPath = matchPath;