1 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
2 |
|
3 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
4 |
|
5 | import React from 'react';
|
6 | import PropTypes from 'prop-types';
|
7 | import hoistStatics from 'hoist-non-react-statics';
|
8 | import Route from './Route';
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | var withRouter = function withRouter(Component) {
|
14 | var C = function C(props) {
|
15 | var wrappedComponentRef = props.wrappedComponentRef,
|
16 | remainingProps = _objectWithoutProperties(props, ['wrappedComponentRef']);
|
17 |
|
18 | return React.createElement(Route, { render: function render(routeComponentProps) {
|
19 | return React.createElement(Component, _extends({}, remainingProps, routeComponentProps, { ref: wrappedComponentRef }));
|
20 | } });
|
21 | };
|
22 |
|
23 | C.displayName = 'withRouter(' + (Component.displayName || Component.name) + ')';
|
24 | C.WrappedComponent = Component;
|
25 | C.propTypes = {
|
26 | wrappedComponentRef: PropTypes.func
|
27 | };
|
28 |
|
29 | return hoistStatics(C, Component);
|
30 | };
|
31 |
|
32 | export default withRouter; |
\ | No newline at end of file |