Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

36 linhas
1.4 KiB

  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. 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; }
  3. import React from "react";
  4. import PropTypes from "prop-types";
  5. import hoistStatics from "hoist-non-react-statics";
  6. import Route from "./Route";
  7. /**
  8. * A public higher-order component to access the imperative API
  9. */
  10. var withRouter = function withRouter(Component) {
  11. var C = function C(props) {
  12. var wrappedComponentRef = props.wrappedComponentRef,
  13. remainingProps = _objectWithoutProperties(props, ["wrappedComponentRef"]);
  14. return React.createElement(Route, {
  15. children: function children(routeComponentProps) {
  16. return React.createElement(Component, _extends({}, remainingProps, routeComponentProps, {
  17. ref: wrappedComponentRef
  18. }));
  19. }
  20. });
  21. };
  22. C.displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
  23. C.WrappedComponent = Component;
  24. C.propTypes = {
  25. wrappedComponentRef: PropTypes.func
  26. };
  27. return hoistStatics(C, Component);
  28. };
  29. export default withRouter;