Exploring lazy pages and routes
In the Avoiding lazy components section, you saw where to avoid making components lazy when there is no benefit in doing so. The same pattern can be applied when you're using react-router
as the mechanism to navigate around your application. Let's take a look at an example. Here are the imports we'll need:
import { BrowserRouter as Router, Routes, Route, Link, Outlet, } from "react-router-dom"; import { FadeLoader } from "react-spinners"; Next, we'll create our lazy components: const First = React.lazy(() => Promise.all([ import("./First"), new Promise((resolve) => { setTimeout(() => { resolve(); }, 3000); }), ]).then...