@shopgate/pwa-common
Version:
Common library for the Shopgate Connect PWA.
59 lines (58 loc) • 1.64 kB
JavaScript
import _createClass from "@babel/runtime/helpers/createClass";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React from 'react';
import PropTypes from 'prop-types';
import { router } from '@virtuous/conductor';
import { RouteContext, RouterContext } from '@virtuous/react-conductor';
import ErrorBoundary from "../ErrorBoundary";
/**
* The RouteNotFound component
*/
import { jsx as _jsx } from "react/jsx-runtime";
let RouteNotFound = /*#__PURE__*/function (_React$Component) {
function RouteNotFound() {
return _React$Component.apply(this, arguments) || this;
}
_inheritsLoose(RouteNotFound, _React$Component);
var _proto = RouteNotFound.prototype;
/**
* @returns {JSX}
*/
_proto.render = function render() {
if (router.match(this.currentRoute.pathname)) {
return null;
}
const {
component: Component
} = this.props;
const {
setPattern,
...context
} = this.currentRoute;
context.open = true;
context.visible = true;
context.pattern = '';
context.is404 = true;
return /*#__PURE__*/_jsx(ErrorBoundary, {
children: /*#__PURE__*/_jsx(RouteContext.Provider, {
value: context,
children: /*#__PURE__*/_jsx(Component, {})
}, "404")
}, "error.404");
};
return _createClass(RouteNotFound, [{
key: "currentRoute",
get:
/**
* @returns {Object}
*/
function () {
const {
[router.routeIndex]: [, route]
} = this.context.stack;
return route;
}
}]);
}(React.Component);
RouteNotFound.contextType = RouterContext;
export default RouteNotFound;