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.
- package/cjs/react-router.js +22 -5
- package/cjs/react-router.js.map +1 -1
- package/cjs/react-router.min.js +1 -1
- package/cjs/react-router.min.js.map +1 -1
- package/es/MemoryRouter.js +0 -2
- package/es/Prompt.js +0 -2
- package/es/Redirect.js +0 -2
- package/es/Route.js +0 -2
- package/es/Router.js +0 -2
- package/es/StaticRouter.js +0 -2
- package/es/Switch.js +0 -2
- package/es/generatePath.js +0 -2
- package/es/matchPath.js +0 -2
- package/es/warnAboutDeprecatedESMImport.js +1 -2
- package/es/withRouter.js +0 -2
- package/esm/react-router.js +22 -6
- package/esm/react-router.js.map +1 -1
- package/modules/HistoryContext.js +4 -0
- package/modules/MemoryRouter.js +1 -1
- package/modules/Prompt.js +2 -2
- package/modules/Redirect.js +3 -3
- package/modules/Route.js +2 -2
- package/modules/Router.js +8 -3
- package/modules/StaticRouter.js +1 -1
- package/modules/Switch.js +2 -2
- package/modules/createNameContext.js +11 -0
- package/modules/hooks.js +6 -4
- package/modules/index.js +12 -11
- package/modules/withRouter.js +2 -1
- package/package.json +5 -9
- package/umd/react-router.js +36 -27
- package/umd/react-router.js.map +1 -1
- package/umd/react-router.min.js +1 -1
- package/umd/react-router.min.js.map +1 -1
- package/warnAboutDeprecatedCJSRequire.js +1 -0
package/umd/react-router.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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-' +
|
|
1626
|
+
var contextProp = '__create-react-context-' + getUniqueId() + '__';
|
|
1631
1627
|
|
|
1632
|
-
var Provider =
|
|
1633
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
|
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
|
|
3036
|
-
var initialBuildName = buildNames[global$1[key
|
|
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
|
|
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;
|