loading...

Redirect with React Router and Hooks

Eric Bishard on April 26, 2019

A lot of these short blog posts are just for me to find later when I forget how to do something, but I thought this little trick that you can do wi... [Read Full]
markdown guide
 

Cool stuff Eric 😮

I've created a Sandbox in case others want to try it out online.

 

Perfect, thanks for doing that. I was planning on doing a few StackBlitz demos for some of the things I cover in this repo. But this will be helpful to those who want to run the code quickly. Thanks for taking the time!

 

You're welcome, Eric and thank you for the post.

The post was worth taking time setting up the sandbox 😀

 

Wow thanks! That was exactly what i needed, but looks hackish though. To me React just doesen't make sense when you can't useHistory (a function) inside useCallback (another function). Is it just me? I'm new to this so i guess i'll figure out why in a while lol.

 

what a simple solution for a learner, especially after spending a day for to find any possible samples. thanks.

 

Thanks for the post! It was exactly what I was looking for.

 

When I want to redirect to admin/diary it works. But when I have admin/diary/:id it gives me a blank page. What could I do?

 

Thanks for the great tutorial. Just a question though. If you try to navigate back to the previous page using your method, that won't work. Do you have any suggestion of how to implement that?

 
 

I have done same thing but when i hit path '/login' or '/signup' , it display url in browser tab('/account/login' || '/account/signup') but does not render related component.

code of conduct - report abuse