There is a main component that handles everything, and I want to show the same main component whenever the URL parameter changes.
So I made this Browser Router structure.
function Router() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="main" element={<Main />}>
<Route path=":id" element={<Main />} />
<Route path="lists/:listId/tasks" element={<Main />} />
<Route path="lists/:listId/tasks/:id" element={<Main />} />
<Route path="all/tasks" element={<Main />} />
<Route path="all/tasks/:id" element={<Main />} />
</Route>
<Route path="signup" element={<SignUp />} />
<Route path="signin" element={<SignIn />} />
<Route
path="requestUpdatePassword"
element={<RequestUpdatePassword />}
/>
<Route path="*" element={<NotFound />} />
</Routes>
</BrowserRouter>
);
}
This causes the main component to be re-rendered every time the URL changes, resulting in poor performance. In v5, I could assign string[] to path of Route, but in v6, I couldn't assign an array.
How can I display multiple URLs in the same component without re-rendering?