Change Link To value on condition

I’m trying to implement a login page for my app.
When the login button is clicked, a fetch is called and tries to login with the user’s info.
If the login succeeds, login button’s value updates to be the homepage, else it changes back to the login page address.
Any idea on how to make it work?
I tried <Link to={redirect?"/home":"/"}> but it didn’t do anything, and I also tried using a state prop which holds the link value but still had problems with it.