Skip to content

Commit 8d2b97e

Browse files
committed
fixed React.lazy imported routes and react-snap compatibility
1 parent 80e0d29 commit 8d2b97e

6 files changed

Lines changed: 20 additions & 29 deletions

File tree

src/front/pages/about/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
import compose from 'recompose/compose';
55
import About from './About';
66
import withEnterAnimation from '../../hoc/withEnterAnimation';
7-
import withSuspense from '../../hoc/withSuspense';
87
// #endregion
98

10-
export default compose(
11-
withEnterAnimation(/* no option yet */),
12-
withSuspense(),
13-
)(About);
9+
export default compose(withEnterAnimation(/* no option yet */))(About);

src/front/pages/home/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
import compose from 'recompose/compose';
55
import Home from './Home';
66
import withEnterAnimation from '../../hoc/withEnterAnimation';
7-
import withSuspense from '../../hoc/withSuspense';
87
// #endregion
98

10-
export default compose(
11-
withEnterAnimation(/* no option yet */),
12-
withSuspense(),
13-
)(Home);
9+
export default compose(withEnterAnimation(/* no option yet */))(Home);

src/front/pages/login/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import compose from 'recompose/compose';
55
import Login from './Login';
66
import withEnterAnimation from '../../hoc/withEnterAnimation';
77
import withAuth from '../../contexts/auth/consumerHOC';
8-
import withSuspense from '../../hoc/withSuspense';
98
// #endregion
109

1110
export default compose(
1211
withEnterAnimation(/* no option yet */),
13-
withSuspense(),
1412
withAuth(),
1513
)(Login);

src/front/pages/pageNotFound/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
import compose from 'recompose/compose';
55
import PageNotFound from './PageNotFound';
66
import withEnterAnimation from '../../hoc/withEnterAnimation';
7-
import withSuspense from '../../hoc/withSuspense';
87
// #endregion
98

10-
export default compose(
11-
withEnterAnimation(/* no option yet */),
12-
withSuspense(),
13-
)(PageNotFound);
9+
export default compose(withEnterAnimation(/* no option yet */))(PageNotFound);

src/front/pages/protected/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
import compose from 'recompose/compose';
55
import Protected from './Protected';
66
import withEnterAnimation from '../../hoc/withEnterAnimation';
7-
import withSuspense from '../../hoc/withSuspense';
87
// #endregion
98

10-
export default compose(
11-
withEnterAnimation(/* no option yet */),
12-
withSuspense(),
13-
)(Protected);
9+
export default compose(withEnterAnimation(/* no option yet */))(Protected);

src/front/routes/MainRoutes.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,35 @@
22

33
// #region imports
44
import React from 'react';
5+
import compose from 'recompose/compose';
6+
import withSuspense from '../hoc/withSuspense';
57
import { Route, Switch } from 'react-router';
68
import PrivateRoute from '../components/privateRoute';
79
// #endregion
810

911
// #region constants
1012
const AsyncHome = React.lazy(() => import('../pages/home'));
11-
// const AsyncAbout = React.lazy(() => import('../pages/about'));
12-
// const AsyncProtected = React.lazy(() => import('../pages/protected'));
13-
// const AsyncPageNotFound = React.lazy(() => import('../pages/pageNotFound'));
13+
const Home = compose(withSuspense())(AsyncHome);
14+
15+
const AsyncAbout = React.lazy(() => import('../pages/about'));
16+
const About = compose(withSuspense())(AsyncAbout);
17+
18+
const AsyncProtected = React.lazy(() => import('../pages/protected'));
19+
const Protected = compose(withSuspense())(AsyncProtected);
20+
21+
const AsyncPageNotFound = React.lazy(() => import('../pages/pageNotFound'));
22+
const PageNotFound = compose(withSuspense())(AsyncPageNotFound);
1423
// #endregion
1524

1625
const MainRoutes = () => {
1726
return (
1827
<Switch>
1928
{/* public views: */}
20-
<Route exact path="/" component={AsyncHome} />
21-
{/* <Route path="/about" component={AsyncAbout} /> */}
29+
<Route exact path="/" component={Home} />
30+
<Route path="/about" component={About} />
2231
{/* private views: need user to be authenticated */}
23-
{/* <PrivateRoute path="/protected" component={AsyncProtected} /> */}
24-
{/* <Route component={AsyncPageNotFound} /> */}
32+
<PrivateRoute path="/protected" component={Protected} />
33+
<Route component={PageNotFound} />
2534
</Switch>
2635
);
2736
};

0 commit comments

Comments
 (0)