The Journey of #100DaysOfCode (@Ayman_Dandan)

๐ƒ๐š๐ฒ ๐Ÿ”๐Ÿ“ of #100DaysOfCode

  • ๐‘ท๐’“๐’๐’ˆ๐’“๐’‚๐’Ž๐’Ž๐’‚๐’•๐’Š๐’„ ๐‘ต๐’‚๐’—๐’Š๐’ˆ๐’‚๐’•๐’Š๐’๐’ ๐’˜๐’Š๐’•๐’‰ ๐‘ต๐’‚๐’—๐’Š๐’ˆ๐’‚๐’•๐’† ๐’‚๐’๐’… ๐’–๐’”๐’†๐‘ต๐’‚๐’—๐’Š๐’ˆ๐’‚๐’•๐’† -

There are times when you need to redirect users programmatically, such as after form submission or authentication. The ๐‘ต๐’‚๐’—๐’Š๐’ˆ๐’‚๐’•๐’† component and the ๐’–๐’”๐’†๐‘ต๐’‚๐’—๐’Š๐’ˆ๐’‚๐’•๐’† hook provide a way to navigate to different routes programmatically.

๐—˜๐˜…๐—ฝ๐—น๐—ฎ๐—ป๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ผ๐—ณ ๐˜๐—ต๐—ฒ ๐—ฎ๐˜๐˜๐—ฎ๐—ฐ๐—ต๐—ฒ๐—ฑ ๐˜€๐—ป๐—ถ๐—ฝ๐—ฝ๐—ฒ๐˜:
โ†’ <Navigate to="/dashboard" replace /> Redirects to the dashboard if the user is logged in.
โ†’ useNavigate(): A hook that returns a function to navigate programmatically.

This is particularly useful for handling user flows that require conditional redirects.

2 Likes