This is not a good practice. You should use an <a /> tag or react-router-dom's <Link /> to handle your redirect. Even if you must redirect programatically, it is better to use a link and use event.preventDefault() on the click and only then use history.push().
There are two reasons why you should do this. Firstly accessibility. Screen readers won't know that your button can redirect. Anchor tags however get properly announced to users using assistive technology. The second reason is web crawlers won't follow your links and you will not get potential SEO benefits from it.
what u say is right. not denying it...but i also think the simple way would come in handy in some cases too. and most practically would be the best option.
This is not a good practice. You should use an
<a />
tag or react-router-dom's<Link />
to handle your redirect. Even if you must redirect programatically, it is better to use a link and useevent.preventDefault()
on the click and only then usehistory.push()
.There are two reasons why you should do this. Firstly accessibility. Screen readers won't know that your button can redirect. Anchor tags however get properly announced to users using assistive technology. The second reason is web crawlers won't follow your links and you will not get potential SEO benefits from it.
what u say is right. not denying it...but i also think the simple way would come in handy in some cases too. and most practically would be the best option.
Thanks for the comment, I forgot to mention that i needed to redirect after logout to Firebase, this snippet code shows more clearly
In this case, do you recommend other approach?
thanks : )