// read location and supply in requireAuth
let location = useLocation()
;<Navigate to='/login' state={{ from: location }} replace />
// use navigate in login to redirect after login
let navigate = useNavigate()
let from = location.state?.from?.pathname || '/'
navigate(from, { replace: true })
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter