react-router 5.0.0 → 5.1.2
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 +102 -66
- package/cjs/react-router.js.map +1 -0
- package/cjs/react-router.min.js +2 -1
- package/cjs/react-router.min.js.map +1 -0
- package/esm/react-router.js +86 -52
- package/esm/react-router.js.map +1 -0
- package/modules/Lifecycle.js +21 -0
- package/modules/MemoryRouter.js +37 -0
- package/modules/Prompt.js +52 -0
- package/modules/Redirect.js +72 -0
- package/modules/Route.js +140 -0
- package/modules/Router.js +83 -0
- package/modules/RouterContext.js +12 -0
- package/modules/StaticRouter.js +102 -0
- package/modules/Switch.js +67 -0
- package/modules/generatePath.js +27 -0
- package/modules/hooks.js +54 -0
- package/modules/index.js +38 -0
- package/modules/matchPath.js +67 -0
- package/modules/withRouter.js +50 -0
- package/package.json +5 -30
- package/umd/react-router.js +580 -568
- package/umd/react-router.js.map +1 -0
- package/umd/react-router.min.js +2 -1
- package/umd/react-router.min.js.map +1 -0
package/esm/react-router.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import createContext from 'create-react-context';
|
|
2
1
|
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
|
-
import warning from 'tiny-warning';
|
|
6
4
|
import { createMemoryHistory, createLocation, locationsAreEqual, createPath } from 'history';
|
|
5
|
+
import warning from 'tiny-warning';
|
|
6
|
+
import createContext from 'mini-create-react-context';
|
|
7
7
|
import invariant from 'tiny-invariant';
|
|
8
|
-
import pathToRegexp from 'path-to-regexp';
|
|
9
8
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
9
|
+
import pathToRegexp from 'path-to-regexp';
|
|
10
10
|
import { isValidElementType } from 'react-is';
|
|
11
11
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';
|
|
12
12
|
import hoistStatics from 'hoist-non-react-statics';
|
|
@@ -15,14 +15,13 @@ import hoistStatics from 'hoist-non-react-statics';
|
|
|
15
15
|
|
|
16
16
|
var createNamedContext = function createNamedContext(name) {
|
|
17
17
|
var context = createContext();
|
|
18
|
-
context.
|
|
19
|
-
context.Consumer.displayName = name + ".Consumer";
|
|
18
|
+
context.displayName = name;
|
|
20
19
|
return context;
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
var context =
|
|
24
23
|
/*#__PURE__*/
|
|
25
|
-
createNamedContext(
|
|
24
|
+
createNamedContext("Router");
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
27
|
* The public API for putting history on context.
|
|
@@ -200,10 +199,10 @@ function Prompt(_ref) {
|
|
|
200
199
|
var message = _ref.message,
|
|
201
200
|
_ref$when = _ref.when,
|
|
202
201
|
when = _ref$when === void 0 ? true : _ref$when;
|
|
203
|
-
return React.createElement(context.Consumer, null, function (context
|
|
204
|
-
!context
|
|
205
|
-
if (!when || context
|
|
206
|
-
var method = context
|
|
202
|
+
return React.createElement(context.Consumer, null, function (context) {
|
|
203
|
+
!context ? process.env.NODE_ENV !== "production" ? invariant(false, "You should not use <Prompt> outside a <Router>") : invariant(false) : void 0;
|
|
204
|
+
if (!when || context.staticContext) return null;
|
|
205
|
+
var method = context.history.block;
|
|
207
206
|
return React.createElement(Lifecycle, {
|
|
208
207
|
onMount: function onMount(self) {
|
|
209
208
|
self.release = method(message);
|
|
@@ -273,10 +272,10 @@ function Redirect(_ref) {
|
|
|
273
272
|
to = _ref.to,
|
|
274
273
|
_ref$push = _ref.push,
|
|
275
274
|
push = _ref$push === void 0 ? false : _ref$push;
|
|
276
|
-
return React.createElement(context.Consumer, null, function (context
|
|
277
|
-
!context
|
|
278
|
-
var history = context
|
|
279
|
-
staticContext = context
|
|
275
|
+
return React.createElement(context.Consumer, null, function (context) {
|
|
276
|
+
!context ? process.env.NODE_ENV !== "production" ? invariant(false, "You should not use <Redirect> outside a <Router>") : invariant(false) : void 0;
|
|
277
|
+
var history = context.history,
|
|
278
|
+
staticContext = context.staticContext;
|
|
280
279
|
var method = push ? history.push : history.replace;
|
|
281
280
|
var location = createLocation(computedMatch ? typeof to === "string" ? generatePath(to, computedMatch.params) : _extends({}, to, {
|
|
282
281
|
pathname: generatePath(to.pathname, computedMatch.params)
|
|
@@ -293,7 +292,11 @@ function Redirect(_ref) {
|
|
|
293
292
|
method(location);
|
|
294
293
|
},
|
|
295
294
|
onUpdate: function onUpdate(self, prevProps) {
|
|
296
|
-
|
|
295
|
+
var prevLocation = createLocation(prevProps.to);
|
|
296
|
+
|
|
297
|
+
if (!locationsAreEqual(prevLocation, _extends({}, location, {
|
|
298
|
+
key: prevLocation.key
|
|
299
|
+
}))) {
|
|
297
300
|
method(location);
|
|
298
301
|
}
|
|
299
302
|
},
|
|
@@ -342,9 +345,12 @@ function matchPath(pathname, options) {
|
|
|
342
345
|
options = {};
|
|
343
346
|
}
|
|
344
347
|
|
|
345
|
-
if (typeof options === "string"
|
|
346
|
-
|
|
347
|
-
|
|
348
|
+
if (typeof options === "string" || Array.isArray(options)) {
|
|
349
|
+
options = {
|
|
350
|
+
path: options
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
|
|
348
354
|
var _options = options,
|
|
349
355
|
path = _options.path,
|
|
350
356
|
_options$exact = _options.exact,
|
|
@@ -355,6 +361,7 @@ function matchPath(pathname, options) {
|
|
|
355
361
|
sensitive = _options$sensitive === void 0 ? false : _options$sensitive;
|
|
356
362
|
var paths = [].concat(path);
|
|
357
363
|
return paths.reduce(function (matched, path) {
|
|
364
|
+
if (!path && path !== "") return null;
|
|
358
365
|
if (matched) return matched;
|
|
359
366
|
|
|
360
367
|
var _compilePath = compilePath$1(path, {
|
|
@@ -389,6 +396,12 @@ function matchPath(pathname, options) {
|
|
|
389
396
|
function isEmptyChildren(children) {
|
|
390
397
|
return React.Children.count(children) === 0;
|
|
391
398
|
}
|
|
399
|
+
|
|
400
|
+
function evalChildrenDev(children, props, path) {
|
|
401
|
+
var value = children(props);
|
|
402
|
+
process.env.NODE_ENV !== "production" ? 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`") : void 0;
|
|
403
|
+
return value || null;
|
|
404
|
+
}
|
|
392
405
|
/**
|
|
393
406
|
* The public API for matching a single path and rendering.
|
|
394
407
|
*/
|
|
@@ -408,13 +421,13 @@ function (_React$Component) {
|
|
|
408
421
|
_proto.render = function render() {
|
|
409
422
|
var _this = this;
|
|
410
423
|
|
|
411
|
-
return React.createElement(context.Consumer, null, function (context
|
|
412
|
-
!context
|
|
413
|
-
var location = _this.props.location || context
|
|
424
|
+
return React.createElement(context.Consumer, null, function (context$1) {
|
|
425
|
+
!context$1 ? process.env.NODE_ENV !== "production" ? invariant(false, "You should not use <Route> outside a <Router>") : invariant(false) : void 0;
|
|
426
|
+
var location = _this.props.location || context$1.location;
|
|
414
427
|
var match = _this.props.computedMatch ? _this.props.computedMatch // <Switch> already computed the match for us
|
|
415
|
-
: _this.props.path ? matchPath(location.pathname, _this.props) : context
|
|
428
|
+
: _this.props.path ? matchPath(location.pathname, _this.props) : context$1.match;
|
|
416
429
|
|
|
417
|
-
var props = _extends({}, context
|
|
430
|
+
var props = _extends({}, context$1, {
|
|
418
431
|
location: location,
|
|
419
432
|
match: match
|
|
420
433
|
});
|
|
@@ -429,22 +442,9 @@ function (_React$Component) {
|
|
|
429
442
|
children = null;
|
|
430
443
|
}
|
|
431
444
|
|
|
432
|
-
if (typeof children === "function") {
|
|
433
|
-
children = children(props);
|
|
434
|
-
|
|
435
|
-
if (children === undefined) {
|
|
436
|
-
if (process.env.NODE_ENV !== "production") {
|
|
437
|
-
var path = _this.props.path;
|
|
438
|
-
process.env.NODE_ENV !== "production" ? warning(false, "You returned `undefined` from the `children` function of " + ("<Route" + (path ? " path=\"" + path + "\"" : "") + ">, but you ") + "should have returned a React element or `null`") : void 0;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
children = null;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
445
|
return React.createElement(context.Provider, {
|
|
446
446
|
value: props
|
|
447
|
-
}, children
|
|
447
|
+
}, props.match ? children ? typeof children === "function" ? process.env.NODE_ENV !== "production" ? evalChildrenDev(children, props, _this.props.path) : children(props) : children : component ? React.createElement(component, props) : render ? render(props) : null : typeof children === "function" ? process.env.NODE_ENV !== "production" ? evalChildrenDev(children, props, _this.props.path) : children(props) : null);
|
|
448
448
|
});
|
|
449
449
|
};
|
|
450
450
|
|
|
@@ -505,7 +505,7 @@ function createURL(location) {
|
|
|
505
505
|
|
|
506
506
|
function staticHandler(methodName) {
|
|
507
507
|
return function () {
|
|
508
|
-
|
|
508
|
+
process.env.NODE_ENV !== "production" ? invariant(false, "You cannot %s with <StaticRouter>", methodName) : invariant(false) ;
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
511
|
|
|
@@ -557,7 +557,8 @@ function (_React$Component) {
|
|
|
557
557
|
var _this$props = this.props,
|
|
558
558
|
_this$props$basename = _this$props.basename,
|
|
559
559
|
basename = _this$props$basename === void 0 ? "" : _this$props$basename,
|
|
560
|
-
context = _this$props.context
|
|
560
|
+
_this$props$context = _this$props.context,
|
|
561
|
+
context = _this$props$context === void 0 ? {} : _this$props$context;
|
|
561
562
|
context.action = action;
|
|
562
563
|
context.location = addBasename(basename, createLocation(location));
|
|
563
564
|
context.url = createURL(context.location);
|
|
@@ -626,9 +627,9 @@ function (_React$Component) {
|
|
|
626
627
|
_proto.render = function render() {
|
|
627
628
|
var _this = this;
|
|
628
629
|
|
|
629
|
-
return React.createElement(context.Consumer, null, function (context
|
|
630
|
-
!context
|
|
631
|
-
var location = _this.props.location || context
|
|
630
|
+
return React.createElement(context.Consumer, null, function (context) {
|
|
631
|
+
!context ? process.env.NODE_ENV !== "production" ? invariant(false, "You should not use <Switch> outside a <Router>") : invariant(false) : void 0;
|
|
632
|
+
var location = _this.props.location || context.location;
|
|
632
633
|
var element, match; // We use React.Children.forEach instead of React.Children.toArray().find()
|
|
633
634
|
// here because toArray adds keys to all child elements and we do not want
|
|
634
635
|
// to trigger an unmount/remount for two <Route>s that render the same
|
|
@@ -640,7 +641,7 @@ function (_React$Component) {
|
|
|
640
641
|
var path = child.props.path || child.props.from;
|
|
641
642
|
match = path ? matchPath(location.pathname, _extends({}, child.props, {
|
|
642
643
|
path: path
|
|
643
|
-
})) : context
|
|
644
|
+
})) : context.match;
|
|
644
645
|
}
|
|
645
646
|
});
|
|
646
647
|
return match ? React.cloneElement(element, {
|
|
@@ -670,31 +671,63 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
670
671
|
*/
|
|
671
672
|
|
|
672
673
|
function withRouter(Component) {
|
|
674
|
+
var displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
|
|
675
|
+
|
|
673
676
|
var C = function C(props) {
|
|
674
677
|
var wrappedComponentRef = props.wrappedComponentRef,
|
|
675
678
|
remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
|
|
676
679
|
|
|
677
|
-
return React.createElement(
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
}
|
|
680
|
+
return React.createElement(context.Consumer, null, function (context) {
|
|
681
|
+
!context ? process.env.NODE_ENV !== "production" ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : invariant(false) : void 0;
|
|
682
|
+
return React.createElement(Component, _extends({}, remainingProps, context, {
|
|
683
|
+
ref: wrappedComponentRef
|
|
684
|
+
}));
|
|
683
685
|
});
|
|
684
686
|
};
|
|
685
687
|
|
|
686
|
-
C.displayName =
|
|
688
|
+
C.displayName = displayName;
|
|
687
689
|
C.WrappedComponent = Component;
|
|
688
690
|
|
|
689
691
|
if (process.env.NODE_ENV !== "production") {
|
|
690
692
|
C.propTypes = {
|
|
691
|
-
wrappedComponentRef: PropTypes.func
|
|
693
|
+
wrappedComponentRef: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object])
|
|
692
694
|
};
|
|
693
695
|
}
|
|
694
696
|
|
|
695
697
|
return hoistStatics(C, Component);
|
|
696
698
|
}
|
|
697
699
|
|
|
700
|
+
var useContext = React.useContext;
|
|
701
|
+
function useHistory() {
|
|
702
|
+
if (process.env.NODE_ENV !== "production") {
|
|
703
|
+
!(typeof useContext === "function") ? process.env.NODE_ENV !== "production" ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : invariant(false) : void 0;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
return useContext(context).history;
|
|
707
|
+
}
|
|
708
|
+
function useLocation() {
|
|
709
|
+
if (process.env.NODE_ENV !== "production") {
|
|
710
|
+
!(typeof useContext === "function") ? process.env.NODE_ENV !== "production" ? invariant(false, "You must use React >= 16.8 in order to use useLocation()") : invariant(false) : void 0;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return useContext(context).location;
|
|
714
|
+
}
|
|
715
|
+
function useParams() {
|
|
716
|
+
if (process.env.NODE_ENV !== "production") {
|
|
717
|
+
!(typeof useContext === "function") ? process.env.NODE_ENV !== "production" ? invariant(false, "You must use React >= 16.8 in order to use useParams()") : invariant(false) : void 0;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
var match = useContext(context).match;
|
|
721
|
+
return match ? match.params : {};
|
|
722
|
+
}
|
|
723
|
+
function useRouteMatch(path) {
|
|
724
|
+
if (process.env.NODE_ENV !== "production") {
|
|
725
|
+
!(typeof useContext === "function") ? process.env.NODE_ENV !== "production" ? invariant(false, "You must use React >= 16.8 in order to use useRouteMatch()") : invariant(false) : void 0;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
return path ? matchPath(useLocation().pathname, path) : useContext(context).match;
|
|
729
|
+
}
|
|
730
|
+
|
|
698
731
|
if (process.env.NODE_ENV !== "production") {
|
|
699
732
|
if (typeof window !== "undefined") {
|
|
700
733
|
var global = window;
|
|
@@ -717,4 +750,5 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
717
750
|
}
|
|
718
751
|
}
|
|
719
752
|
|
|
720
|
-
export { MemoryRouter, Prompt, Redirect, Route, Router, StaticRouter, Switch, generatePath, matchPath,
|
|
753
|
+
export { MemoryRouter, Prompt, Redirect, Route, Router, StaticRouter, Switch, context as __RouterContext, generatePath, matchPath, useHistory, useLocation, useParams, useRouteMatch, withRouter };
|
|
754
|
+
//# sourceMappingURL=react-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-router.js","sources":["../modules/RouterContext.js","../modules/Router.js","../modules/MemoryRouter.js","../modules/Lifecycle.js","../modules/Prompt.js","../modules/generatePath.js","../modules/Redirect.js","../modules/matchPath.js","../modules/Route.js","../modules/StaticRouter.js","../modules/Switch.js","../modules/withRouter.js","../modules/hooks.js","../modules/index.js"],"sourcesContent":["// TODO: Replace with React.createContext once we can assume React 16+\nimport createContext from \"mini-create-react-context\";\n\nconst createNamedContext = name => {\n const context = createContext();\n context.displayName = name;\n\n return context;\n};\n\nconst context = /*#__PURE__*/ createNamedContext(\"Router\");\nexport default context;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport warning from \"tiny-warning\";\n\nimport RouterContext from \"./RouterContext\";\n\n/**\n * The public API for putting history on context.\n */\nclass Router extends React.Component {\n static computeRootMatch(pathname) {\n return { path: \"/\", url: \"/\", params: {}, isExact: pathname === \"/\" };\n }\n\n constructor(props) {\n super(props);\n\n this.state = {\n location: props.history.location\n };\n\n // This is a bit of a hack. We have to start listening for location\n // changes here in the constructor in case there are any <Redirect>s\n // on the initial render. If there are, they will replace/push when\n // they mount and since cDM fires in children before parents, we may\n // get a new location before the <Router> is mounted.\n this._isMounted = false;\n this._pendingLocation = null;\n\n if (!props.staticContext) {\n this.unlisten = props.history.listen(location => {\n if (this._isMounted) {\n this.setState({ location });\n } else {\n this._pendingLocation = location;\n }\n });\n }\n }\n\n componentDidMount() {\n this._isMounted = true;\n\n if (this._pendingLocation) {\n this.setState({ location: this._pendingLocation });\n }\n }\n\n componentWillUnmount() {\n if (this.unlisten) this.unlisten();\n }\n\n render() {\n return (\n <RouterContext.Provider\n children={this.props.children || null}\n value={{\n history: this.props.history,\n location: this.state.location,\n match: Router.computeRootMatch(this.state.location.pathname),\n staticContext: this.props.staticContext\n }}\n />\n );\n }\n}\n\nif (__DEV__) {\n Router.propTypes = {\n children: PropTypes.node,\n history: PropTypes.object.isRequired,\n staticContext: PropTypes.object\n };\n\n Router.prototype.componentDidUpdate = function(prevProps) {\n warning(\n prevProps.history === this.props.history,\n \"You cannot change <Router history>\"\n );\n };\n}\n\nexport default Router;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { createMemoryHistory as createHistory } from \"history\";\nimport warning from \"tiny-warning\";\n\nimport Router from \"./Router\";\n\n/**\n * The public API for a <Router> that stores location in memory.\n */\nclass MemoryRouter extends React.Component {\n history = createHistory(this.props);\n\n render() {\n return <Router history={this.history} children={this.props.children} />;\n }\n}\n\nif (__DEV__) {\n MemoryRouter.propTypes = {\n initialEntries: PropTypes.array,\n initialIndex: PropTypes.number,\n getUserConfirmation: PropTypes.func,\n keyLength: PropTypes.number,\n children: PropTypes.node\n };\n\n MemoryRouter.prototype.componentDidMount = function() {\n warning(\n !this.props.history,\n \"<MemoryRouter> ignores the history prop. To use a custom history, \" +\n \"use `import { Router }` instead of `import { MemoryRouter as Router }`.\"\n );\n };\n}\n\nexport default MemoryRouter;\n","import React from \"react\";\n\nclass Lifecycle extends React.Component {\n componentDidMount() {\n if (this.props.onMount) this.props.onMount.call(this, this);\n }\n\n componentDidUpdate(prevProps) {\n if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);\n }\n\n componentWillUnmount() {\n if (this.props.onUnmount) this.props.onUnmount.call(this, this);\n }\n\n render() {\n return null;\n }\n}\n\nexport default Lifecycle;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\n\nimport Lifecycle from \"./Lifecycle\";\nimport RouterContext from \"./RouterContext\";\n\n/**\n * The public API for prompting the user before navigating away from a screen.\n */\nfunction Prompt({ message, when = true }) {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Prompt> outside a <Router>\");\n\n if (!when || context.staticContext) return null;\n\n const method = context.history.block;\n\n return (\n <Lifecycle\n onMount={self => {\n self.release = method(message);\n }}\n onUpdate={(self, prevProps) => {\n if (prevProps.message !== message) {\n self.release();\n self.release = method(message);\n }\n }}\n onUnmount={self => {\n self.release();\n }}\n message={message}\n />\n );\n }}\n </RouterContext.Consumer>\n );\n}\n\nif (__DEV__) {\n const messageType = PropTypes.oneOfType([PropTypes.func, PropTypes.string]);\n\n Prompt.propTypes = {\n when: PropTypes.bool,\n message: messageType.isRequired\n };\n}\n\nexport default Prompt;\n","import pathToRegexp from \"path-to-regexp\";\n\nconst cache = {};\nconst cacheLimit = 10000;\nlet cacheCount = 0;\n\nfunction compilePath(path) {\n if (cache[path]) return cache[path];\n\n const generator = pathToRegexp.compile(path);\n\n if (cacheCount < cacheLimit) {\n cache[path] = generator;\n cacheCount++;\n }\n\n return generator;\n}\n\n/**\n * Public API for generating a URL pathname from a path and parameters.\n */\nfunction generatePath(path = \"/\", params = {}) {\n return path === \"/\" ? path : compilePath(path)(params, { pretty: true });\n}\n\nexport default generatePath;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { createLocation, locationsAreEqual } from \"history\";\nimport invariant from \"tiny-invariant\";\n\nimport Lifecycle from \"./Lifecycle\";\nimport RouterContext from \"./RouterContext\";\nimport generatePath from \"./generatePath\";\n\n/**\n * The public API for navigating programmatically with a component.\n */\nfunction Redirect({ computedMatch, to, push = false }) {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Redirect> outside a <Router>\");\n\n const { history, staticContext } = context;\n\n const method = push ? history.push : history.replace;\n const location = createLocation(\n computedMatch\n ? typeof to === \"string\"\n ? generatePath(to, computedMatch.params)\n : {\n ...to,\n pathname: generatePath(to.pathname, computedMatch.params)\n }\n : to\n );\n\n // When rendering in a static context,\n // set the new location immediately.\n if (staticContext) {\n method(location);\n return null;\n }\n\n return (\n <Lifecycle\n onMount={() => {\n method(location);\n }}\n onUpdate={(self, prevProps) => {\n const prevLocation = createLocation(prevProps.to);\n if (\n !locationsAreEqual(prevLocation, {\n ...location,\n key: prevLocation.key\n })\n ) {\n method(location);\n }\n }}\n to={to}\n />\n );\n }}\n </RouterContext.Consumer>\n );\n}\n\nif (__DEV__) {\n Redirect.propTypes = {\n push: PropTypes.bool,\n from: PropTypes.string,\n to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired\n };\n}\n\nexport default Redirect;\n","import pathToRegexp from \"path-to-regexp\";\n\nconst cache = {};\nconst cacheLimit = 10000;\nlet cacheCount = 0;\n\nfunction compilePath(path, options) {\n const cacheKey = `${options.end}${options.strict}${options.sensitive}`;\n const pathCache = cache[cacheKey] || (cache[cacheKey] = {});\n\n if (pathCache[path]) return pathCache[path];\n\n const keys = [];\n const regexp = pathToRegexp(path, keys, options);\n const result = { regexp, keys };\n\n if (cacheCount < cacheLimit) {\n pathCache[path] = result;\n cacheCount++;\n }\n\n return result;\n}\n\n/**\n * Public API for matching a URL pathname to a path.\n */\nfunction matchPath(pathname, options = {}) {\n if (typeof options === \"string\" || Array.isArray(options)) {\n options = { path: options };\n }\n\n const { path, exact = false, strict = false, sensitive = false } = options;\n\n const paths = [].concat(path);\n\n return paths.reduce((matched, path) => {\n if (!path && path !== \"\") return null;\n if (matched) return matched;\n\n const { regexp, keys } = compilePath(path, {\n end: exact,\n strict,\n sensitive\n });\n const match = regexp.exec(pathname);\n\n if (!match) return null;\n\n const [url, ...values] = match;\n const isExact = pathname === url;\n\n if (exact && !isExact) return null;\n\n return {\n path, // the path used to match\n url: path === \"/\" && url === \"\" ? \"/\" : url, // the matched portion of the URL\n isExact, // whether or not we matched exactly\n params: keys.reduce((memo, key, index) => {\n memo[key.name] = values[index];\n return memo;\n }, {})\n };\n }, null);\n}\n\nexport default matchPath;\n","import React from \"react\";\nimport { isValidElementType } from \"react-is\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\nimport warning from \"tiny-warning\";\n\nimport RouterContext from \"./RouterContext\";\nimport matchPath from \"./matchPath\";\n\nfunction isEmptyChildren(children) {\n return React.Children.count(children) === 0;\n}\n\nfunction evalChildrenDev(children, props, path) {\n const value = children(props);\n\n warning(\n value !== undefined,\n \"You returned `undefined` from the `children` function of \" +\n `<Route${path ? ` path=\"${path}\"` : \"\"}>, but you ` +\n \"should have returned a React element or `null`\"\n );\n\n return value || null;\n}\n\n/**\n * The public API for matching a single path and rendering.\n */\nclass Route extends React.Component {\n render() {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Route> outside a <Router>\");\n\n const location = this.props.location || context.location;\n const match = this.props.computedMatch\n ? this.props.computedMatch // <Switch> already computed the match for us\n : this.props.path\n ? matchPath(location.pathname, this.props)\n : context.match;\n\n const props = { ...context, location, match };\n\n let { children, component, render } = this.props;\n\n // Preact uses an empty array as children by\n // default, so use null if that's the case.\n if (Array.isArray(children) && children.length === 0) {\n children = null;\n }\n\n return (\n <RouterContext.Provider value={props}>\n {props.match\n ? children\n ? typeof children === \"function\"\n ? __DEV__\n ? evalChildrenDev(children, props, this.props.path)\n : children(props)\n : children\n : component\n ? React.createElement(component, props)\n : render\n ? render(props)\n : null\n : typeof children === \"function\"\n ? __DEV__\n ? evalChildrenDev(children, props, this.props.path)\n : children(props)\n : null}\n </RouterContext.Provider>\n );\n }}\n </RouterContext.Consumer>\n );\n }\n}\n\nif (__DEV__) {\n Route.propTypes = {\n children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),\n component: (props, propName) => {\n if (props[propName] && !isValidElementType(props[propName])) {\n return new Error(\n `Invalid prop 'component' supplied to 'Route': the prop is not a valid React component`\n );\n }\n },\n exact: PropTypes.bool,\n location: PropTypes.object,\n path: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.arrayOf(PropTypes.string)\n ]),\n render: PropTypes.func,\n sensitive: PropTypes.bool,\n strict: PropTypes.bool\n };\n\n Route.prototype.componentDidMount = function() {\n warning(\n !(\n this.props.children &&\n !isEmptyChildren(this.props.children) &&\n this.props.component\n ),\n \"You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored\"\n );\n\n warning(\n !(\n this.props.children &&\n !isEmptyChildren(this.props.children) &&\n this.props.render\n ),\n \"You should not use <Route render> and <Route children> in the same route; <Route render> will be ignored\"\n );\n\n warning(\n !(this.props.component && this.props.render),\n \"You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored\"\n );\n };\n\n Route.prototype.componentDidUpdate = function(prevProps) {\n warning(\n !(this.props.location && !prevProps.location),\n '<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.'\n );\n\n warning(\n !(!this.props.location && prevProps.location),\n '<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.'\n );\n };\n}\n\nexport default Route;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { createLocation, createPath } from \"history\";\nimport invariant from \"tiny-invariant\";\nimport warning from \"tiny-warning\";\n\nimport Router from \"./Router\";\n\nfunction addLeadingSlash(path) {\n return path.charAt(0) === \"/\" ? path : \"/\" + path;\n}\n\nfunction addBasename(basename, location) {\n if (!basename) return location;\n\n return {\n ...location,\n pathname: addLeadingSlash(basename) + location.pathname\n };\n}\n\nfunction stripBasename(basename, location) {\n if (!basename) return location;\n\n const base = addLeadingSlash(basename);\n\n if (location.pathname.indexOf(base) !== 0) return location;\n\n return {\n ...location,\n pathname: location.pathname.substr(base.length)\n };\n}\n\nfunction createURL(location) {\n return typeof location === \"string\" ? location : createPath(location);\n}\n\nfunction staticHandler(methodName) {\n return () => {\n invariant(false, \"You cannot %s with <StaticRouter>\", methodName);\n };\n}\n\nfunction noop() {}\n\n/**\n * The public top-level API for a \"static\" <Router>, so-called because it\n * can't actually change the current location. Instead, it just records\n * location changes in a context object. Useful mainly in testing and\n * server-rendering scenarios.\n */\nclass StaticRouter extends React.Component {\n navigateTo(location, action) {\n const { basename = \"\", context = {} } = this.props;\n context.action = action;\n context.location = addBasename(basename, createLocation(location));\n context.url = createURL(context.location);\n }\n\n handlePush = location => this.navigateTo(location, \"PUSH\");\n handleReplace = location => this.navigateTo(location, \"REPLACE\");\n handleListen = () => noop;\n handleBlock = () => noop;\n\n render() {\n const { basename = \"\", context = {}, location = \"/\", ...rest } = this.props;\n\n const history = {\n createHref: path => addLeadingSlash(basename + createURL(path)),\n action: \"POP\",\n location: stripBasename(basename, createLocation(location)),\n push: this.handlePush,\n replace: this.handleReplace,\n go: staticHandler(\"go\"),\n goBack: staticHandler(\"goBack\"),\n goForward: staticHandler(\"goForward\"),\n listen: this.handleListen,\n block: this.handleBlock\n };\n\n return <Router {...rest} history={history} staticContext={context} />;\n }\n}\n\nif (__DEV__) {\n StaticRouter.propTypes = {\n basename: PropTypes.string,\n context: PropTypes.object,\n location: PropTypes.oneOfType([PropTypes.string, PropTypes.object])\n };\n\n StaticRouter.prototype.componentDidMount = function() {\n warning(\n !this.props.history,\n \"<StaticRouter> ignores the history prop. To use a custom history, \" +\n \"use `import { Router }` instead of `import { StaticRouter as Router }`.\"\n );\n };\n}\n\nexport default StaticRouter;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport invariant from \"tiny-invariant\";\nimport warning from \"tiny-warning\";\n\nimport RouterContext from \"./RouterContext\";\nimport matchPath from \"./matchPath\";\n\n/**\n * The public API for rendering the first <Route> that matches.\n */\nclass Switch extends React.Component {\n render() {\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(context, \"You should not use <Switch> outside a <Router>\");\n\n const location = this.props.location || context.location;\n\n let element, match;\n\n // We use React.Children.forEach instead of React.Children.toArray().find()\n // here because toArray adds keys to all child elements and we do not want\n // to trigger an unmount/remount for two <Route>s that render the same\n // component at different URLs.\n React.Children.forEach(this.props.children, child => {\n if (match == null && React.isValidElement(child)) {\n element = child;\n\n const path = child.props.path || child.props.from;\n\n match = path\n ? matchPath(location.pathname, { ...child.props, path })\n : context.match;\n }\n });\n\n return match\n ? React.cloneElement(element, { location, computedMatch: match })\n : null;\n }}\n </RouterContext.Consumer>\n );\n }\n}\n\nif (__DEV__) {\n Switch.propTypes = {\n children: PropTypes.node,\n location: PropTypes.object\n };\n\n Switch.prototype.componentDidUpdate = function(prevProps) {\n warning(\n !(this.props.location && !prevProps.location),\n '<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.'\n );\n\n warning(\n !(!this.props.location && prevProps.location),\n '<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.'\n );\n };\n}\n\nexport default Switch;\n","import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport RouterContext from \"./RouterContext\";\nimport hoistStatics from \"hoist-non-react-statics\";\nimport invariant from \"tiny-invariant\";\n\n/**\n * A public higher-order component to access the imperative API\n */\nfunction withRouter(Component) {\n const displayName = `withRouter(${Component.displayName || Component.name})`;\n const C = props => {\n const { wrappedComponentRef, ...remainingProps } = props;\n\n return (\n <RouterContext.Consumer>\n {context => {\n invariant(\n context,\n `You should not use <${displayName} /> outside a <Router>`\n );\n return (\n <Component\n {...remainingProps}\n {...context}\n ref={wrappedComponentRef}\n />\n );\n }}\n </RouterContext.Consumer>\n );\n };\n\n C.displayName = displayName;\n C.WrappedComponent = Component;\n\n if (__DEV__) {\n C.propTypes = {\n wrappedComponentRef: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.func,\n PropTypes.object\n ])\n };\n }\n\n return hoistStatics(C, Component);\n}\n\nexport default withRouter;\n","import React from \"react\";\nimport invariant from \"tiny-invariant\";\n\nimport Context from \"./RouterContext.js\";\nimport matchPath from \"./matchPath.js\";\n\nconst useContext = React.useContext;\n\nexport function useHistory() {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useHistory()\"\n );\n }\n\n return useContext(Context).history;\n}\n\nexport function useLocation() {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useLocation()\"\n );\n }\n\n return useContext(Context).location;\n}\n\nexport function useParams() {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useParams()\"\n );\n }\n\n const match = useContext(Context).match;\n return match ? match.params : {};\n}\n\nexport function useRouteMatch(path) {\n if (__DEV__) {\n invariant(\n typeof useContext === \"function\",\n \"You must use React >= 16.8 in order to use useRouteMatch()\"\n );\n }\n\n return path\n ? matchPath(useLocation().pathname, path)\n : useContext(Context).match;\n}\n","if (__DEV__) {\n if (typeof window !== \"undefined\") {\n const global = window;\n const key = \"__react_router_build__\";\n const buildNames = { cjs: \"CommonJS\", esm: \"ES modules\", umd: \"UMD\" };\n\n if (global[key] && global[key] !== process.env.BUILD_FORMAT) {\n const initialBuildName = buildNames[global[key]];\n const secondaryBuildName = buildNames[process.env.BUILD_FORMAT];\n\n // TODO: Add link to article that explains in detail how to avoid\n // loading 2 different builds.\n throw new Error(\n `You are loading the ${secondaryBuildName} build of React Router ` +\n `on a page that is already running the ${initialBuildName} ` +\n `build, so things won't work right.`\n );\n }\n\n global[key] = process.env.BUILD_FORMAT;\n }\n}\n\nexport { default as MemoryRouter } from \"./MemoryRouter\";\nexport { default as Prompt } from \"./Prompt\";\nexport { default as Redirect } from \"./Redirect\";\nexport { default as Route } from \"./Route\";\nexport { default as Router } from \"./Router\";\nexport { default as StaticRouter } from \"./StaticRouter\";\nexport { default as Switch } from \"./Switch\";\nexport { default as generatePath } from \"./generatePath\";\nexport { default as matchPath } from \"./matchPath\";\nexport { default as withRouter } from \"./withRouter\";\n\nimport { useHistory, useLocation, useParams, useRouteMatch } from \"./hooks.js\";\nexport { useHistory, useLocation, useParams, useRouteMatch };\n\nexport { default as __RouterContext } from \"./RouterContext\";\n"],"names":["createNamedContext","name","context","createContext","displayName","Router","computeRootMatch","pathname","path","url","params","isExact","props","state","location","history","_isMounted","_pendingLocation","staticContext","unlisten","listen","setState","componentDidMount","componentWillUnmount","render","RouterContext","children","match","React","Component","propTypes","PropTypes","node","object","isRequired","prototype","componentDidUpdate","prevProps","warning","MemoryRouter","createHistory","initialEntries","array","initialIndex","number","getUserConfirmation","func","keyLength","Lifecycle","onMount","call","onUpdate","onUnmount","Prompt","message","when","invariant","method","block","self","release","messageType","oneOfType","string","bool","cache","cacheLimit","cacheCount","compilePath","generator","pathToRegexp","compile","generatePath","pretty","Redirect","computedMatch","to","push","replace","createLocation","prevLocation","locationsAreEqual","key","from","options","cacheKey","end","strict","sensitive","pathCache","keys","regexp","result","matchPath","Array","isArray","exact","paths","concat","reduce","matched","exec","values","memo","index","isEmptyChildren","Children","count","evalChildrenDev","value","undefined","Route","component","length","createElement","propName","isValidElementType","Error","arrayOf","addLeadingSlash","charAt","addBasename","basename","stripBasename","base","indexOf","substr","createURL","createPath","staticHandler","methodName","noop","StaticRouter","handlePush","navigateTo","handleReplace","handleListen","handleBlock","action","rest","createHref","go","goBack","goForward","Switch","element","forEach","child","isValidElement","cloneElement","withRouter","C","wrappedComponentRef","remainingProps","WrappedComponent","hoistStatics","useContext","useHistory","Context","useLocation","useParams","useRouteMatch","window","global","buildNames","cjs","esm","umd","process","initialBuildName","secondaryBuildName"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAEA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAAAC,IAAI,EAAI;MAC3BC,OAAO,GAAGC,aAAa,EAA7B;EACAD,OAAO,CAACE,WAAR,GAAsBH,IAAtB;SAEOC,OAAP;CAJF;;AAOA,IAAMA,OAAO;;AAAiBF,kBAAkB,CAAC,QAAD,CAAhD;;ACJA;;;;IAGMK;;;;;SACGC,mBAAP,0BAAwBC,QAAxB,EAAkC;WACzB;MAAEC,IAAI,EAAE,GAAR;MAAaC,GAAG,EAAE,GAAl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nI,KAFxB;;;AClDF,2CAAa;MACP,OAAOuI,MAAP,KAAkB,WAAtB,EAAmC;QAC3BC,MAAM,GAAGD,MAAf;QACMhF,GAAG,GAAG,wBAAZ;QACMkF,UAAU,GAAG;MAAEC,GAAG,EAAE,UAAP;MAAmBC,GAAG,EAAE,YAAxB;MAAsCC,GAAG,EAAE;KAA9D;;QAEIJ,MAAM,CAACjF,GAAD,CAAN,IAAeiF,MAAM,CAACjF,GAAD,CAAN,KAAgBsF,KAAnC,EAA6D;UACrDC,gBAAgB,GAAGL,UAAU,CAACD,MAAM,CAACjF,GAAD,CAAP,CAAnC;UACMwF,kBAAkB,GAAGN,UAAU,CAACI,KAAD,CAArC,CAF2D;;;YAMrD,IAAInD,KAAJ,CACJ,yBAAuBqD,kBAAvB,2EAC2CD,gBAD3C,8CADI,CAAN;;;IAOFN,MAAM,CAACjF,GAAD,CAAN,GAAcsF,KAAd;;;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
class Lifecycle extends React.Component {
|
|
4
|
+
componentDidMount() {
|
|
5
|
+
if (this.props.onMount) this.props.onMount.call(this, this);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
componentDidUpdate(prevProps) {
|
|
9
|
+
if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
componentWillUnmount() {
|
|
13
|
+
if (this.props.onUnmount) this.props.onUnmount.call(this, this);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
render() {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default Lifecycle;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { createMemoryHistory as createHistory } from "history";
|
|
4
|
+
import warning from "tiny-warning";
|
|
5
|
+
|
|
6
|
+
import Router from "./Router";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The public API for a <Router> that stores location in memory.
|
|
10
|
+
*/
|
|
11
|
+
class MemoryRouter extends React.Component {
|
|
12
|
+
history = createHistory(this.props);
|
|
13
|
+
|
|
14
|
+
render() {
|
|
15
|
+
return <Router history={this.history} children={this.props.children} />;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (__DEV__) {
|
|
20
|
+
MemoryRouter.propTypes = {
|
|
21
|
+
initialEntries: PropTypes.array,
|
|
22
|
+
initialIndex: PropTypes.number,
|
|
23
|
+
getUserConfirmation: PropTypes.func,
|
|
24
|
+
keyLength: PropTypes.number,
|
|
25
|
+
children: PropTypes.node
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
MemoryRouter.prototype.componentDidMount = function() {
|
|
29
|
+
warning(
|
|
30
|
+
!this.props.history,
|
|
31
|
+
"<MemoryRouter> ignores the history prop. To use a custom history, " +
|
|
32
|
+
"use `import { Router }` instead of `import { MemoryRouter as Router }`."
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default MemoryRouter;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import invariant from "tiny-invariant";
|
|
4
|
+
|
|
5
|
+
import Lifecycle from "./Lifecycle";
|
|
6
|
+
import RouterContext from "./RouterContext";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The public API for prompting the user before navigating away from a screen.
|
|
10
|
+
*/
|
|
11
|
+
function Prompt({ message, when = true }) {
|
|
12
|
+
return (
|
|
13
|
+
<RouterContext.Consumer>
|
|
14
|
+
{context => {
|
|
15
|
+
invariant(context, "You should not use <Prompt> outside a <Router>");
|
|
16
|
+
|
|
17
|
+
if (!when || context.staticContext) return null;
|
|
18
|
+
|
|
19
|
+
const method = context.history.block;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Lifecycle
|
|
23
|
+
onMount={self => {
|
|
24
|
+
self.release = method(message);
|
|
25
|
+
}}
|
|
26
|
+
onUpdate={(self, prevProps) => {
|
|
27
|
+
if (prevProps.message !== message) {
|
|
28
|
+
self.release();
|
|
29
|
+
self.release = method(message);
|
|
30
|
+
}
|
|
31
|
+
}}
|
|
32
|
+
onUnmount={self => {
|
|
33
|
+
self.release();
|
|
34
|
+
}}
|
|
35
|
+
message={message}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}}
|
|
39
|
+
</RouterContext.Consumer>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (__DEV__) {
|
|
44
|
+
const messageType = PropTypes.oneOfType([PropTypes.func, PropTypes.string]);
|
|
45
|
+
|
|
46
|
+
Prompt.propTypes = {
|
|
47
|
+
when: PropTypes.bool,
|
|
48
|
+
message: messageType.isRequired
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default Prompt;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { createLocation, locationsAreEqual } from "history";
|
|
4
|
+
import invariant from "tiny-invariant";
|
|
5
|
+
|
|
6
|
+
import Lifecycle from "./Lifecycle";
|
|
7
|
+
import RouterContext from "./RouterContext";
|
|
8
|
+
import generatePath from "./generatePath";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The public API for navigating programmatically with a component.
|
|
12
|
+
*/
|
|
13
|
+
function Redirect({ computedMatch, to, push = false }) {
|
|
14
|
+
return (
|
|
15
|
+
<RouterContext.Consumer>
|
|
16
|
+
{context => {
|
|
17
|
+
invariant(context, "You should not use <Redirect> outside a <Router>");
|
|
18
|
+
|
|
19
|
+
const { history, staticContext } = context;
|
|
20
|
+
|
|
21
|
+
const method = push ? history.push : history.replace;
|
|
22
|
+
const location = createLocation(
|
|
23
|
+
computedMatch
|
|
24
|
+
? typeof to === "string"
|
|
25
|
+
? generatePath(to, computedMatch.params)
|
|
26
|
+
: {
|
|
27
|
+
...to,
|
|
28
|
+
pathname: generatePath(to.pathname, computedMatch.params)
|
|
29
|
+
}
|
|
30
|
+
: to
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// When rendering in a static context,
|
|
34
|
+
// set the new location immediately.
|
|
35
|
+
if (staticContext) {
|
|
36
|
+
method(location);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Lifecycle
|
|
42
|
+
onMount={() => {
|
|
43
|
+
method(location);
|
|
44
|
+
}}
|
|
45
|
+
onUpdate={(self, prevProps) => {
|
|
46
|
+
const prevLocation = createLocation(prevProps.to);
|
|
47
|
+
if (
|
|
48
|
+
!locationsAreEqual(prevLocation, {
|
|
49
|
+
...location,
|
|
50
|
+
key: prevLocation.key
|
|
51
|
+
})
|
|
52
|
+
) {
|
|
53
|
+
method(location);
|
|
54
|
+
}
|
|
55
|
+
}}
|
|
56
|
+
to={to}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}}
|
|
60
|
+
</RouterContext.Consumer>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (__DEV__) {
|
|
65
|
+
Redirect.propTypes = {
|
|
66
|
+
push: PropTypes.bool,
|
|
67
|
+
from: PropTypes.string,
|
|
68
|
+
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default Redirect;
|