Skip to content

Commit

Permalink
fix(redirect): issues/328 lazy load routing
Browse files Browse the repository at this point in the history
* redirect, apply suspense for lazy loaded redirect route
  • Loading branch information
cdcabrera committed Jul 17, 2020
1 parent 30d3650 commit b7436ee
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/router/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import { withRouter, Route } from 'react-router-dom';
import { routerHelpers } from './routerHelpers';
import { helpers } from '../../common';
import { Loader } from '../loader/loader';

/**
* A routing redirect.
Expand Down Expand Up @@ -31,7 +32,12 @@ const Redirect = ({ baseName, history, isRedirect, isReplace, url, route }) => {
if (isRedirect === true) {
if (route && history) {
const routeDetail = routerHelpers.getRouteDetail({ pathname: route });
return <Route path="*">{routeDetail && <routeDetail.component />}</Route>;

return (
<React.Suspense fallback={<Loader variant="title" />}>
<Route path="*">{routeDetail && <routeDetail.component />}</Route>
</React.Suspense>
);
}

const forcePath = url || (route && path.join(baseName, route));
Expand Down

0 comments on commit b7436ee

Please sign in to comment.