Answers
- The
HomePage
component will be rendered when the browser location is/
, and theSearchPage
component will be rendered when the browser location is/search
. - To enable a path of
/login
to render the sign-in page, we can define an additionalRoute
component as follows:<Route path="signin" element={<SignInPage />} /> <Route path="login" element={<SignInPage />} />
- The
NotFoundPage
component will be rendered. - We can reference the
userId
route parameter using theuseParams
hook as follows:const { userId } = useParams();
- We can reference the
id
query parameter using theuseSearchParams
hook as follows:const [searchParams] = useSearchParams(); const id = searchParams.get('id');
- The
Link
component can be used so that navigation only happens on the client:<Link to="products">Products</Link>
- In order to programmatically navigate, we first need to get a function from the
useNavigate...