with-router.js 1.3 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = withRouter;
  6. var _interop_require_default = require("@swc/helpers/lib/_interop_require_default.js").default;
  7. var _react = _interop_require_default(require("react"));
  8. var _router = require("./router");
  9. function withRouter(ComposedComponent) {
  10. function WithRouterWrapper(props) {
  11. return /*#__PURE__*/ _react.default.createElement(ComposedComponent, Object.assign({
  12. router: (0, _router).useRouter()
  13. }, props));
  14. }
  15. WithRouterWrapper.getInitialProps = ComposedComponent.getInitialProps;
  16. WithRouterWrapper.origGetInitialProps = ComposedComponent.origGetInitialProps;
  17. if (process.env.NODE_ENV !== 'production') {
  18. const name = ComposedComponent.displayName || ComposedComponent.name || 'Unknown';
  19. WithRouterWrapper.displayName = `withRouter(${name})`;
  20. }
  21. return WithRouterWrapper;
  22. }
  23. if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
  24. Object.defineProperty(exports.default, '__esModule', { value: true });
  25. Object.assign(exports.default, exports);
  26. module.exports = exports.default;
  27. }
  28. //# sourceMappingURL=with-router.js.map