Skip to content

Commit

Permalink
Update App.jsx
Browse files Browse the repository at this point in the history
add Suspense to lazy Cast & Reviews
  • Loading branch information
danretegan committed Feb 15, 2024
1 parent 492a4a7 commit 02a5d3e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { lazy } from 'react';
import React, { Suspense, lazy } from 'react';
import { Route, Routes } from 'react-router-dom';

import Home from '../pages/Home';
Expand All @@ -19,8 +19,22 @@ const App = () => {
<Route index element={<Home />} />
<Route path="movies" element={<Movies />} />
<Route path="movies/:movieId" element={<MovieDetails />}>
<Route path="cast" element={<Cast />} />
<Route path="reviews" element={<Reviews />} />
<Route
path="cast"
element={
<Suspense fallback={<div>Loading...</div>}>
<Cast />
</Suspense>
}
/>
<Route
path="reviews"
element={
<Suspense fallback={<div>Loading...</div>}>
<Reviews />
</Suspense>
}
/>
</Route>
<Route path="*" element={<NotFoundPage />} />
</Route>
Expand Down

0 comments on commit 02a5d3e

Please sign in to comment.