What is the difference between Navigate
component and navigate
from useNavigate()
hook?.
if (therapy !== desiredGroupTherapy || required.includes('admin') && !isAdmin) {
const pathname = generatePath(pageRoutes.DASHBOARD, {
groupId: desiredGroupId,
therapy: therapyForValidGroup,
})
navigate(pathname, { replace: true })
// return <Navigate to={pathname} replace />
}
I have issue with navigate
here. How that should work: I redirect to that page, but at first time I have no therapy
, so I should redirect to the same page but my therapy
now will be equal to therapyForValidGroup
. I have custom hook useTherapy()
which takes therapy
from URL. So at first time when it is undefined it crashes using navigate
function. But using Navigate
component, it works fine. So what is the difference?