Answers
- The
HomePagecomponent will be rendered when the browser location is/, and theSearchPagecomponent will be rendered when the browser location is/search. - To enable a path of
/loginto render the sign-in page, we can define an additionalRoutecomponent as follows:<Route path="signin" element={<SignInPage />} /> <Route path="login" element={<SignInPage />} /> - The
NotFoundPagecomponent will be rendered. - We can reference the
userIdroute parameter using theuseParamshook as follows:const { userId } = useParams(); - We can reference the
idquery parameter using theuseSearchParamshook as follows:const [searchParams] = useSearchParams(); const id = searchParams.get('id'); - The
Linkcomponent 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...