Sync URL with State
Unanswered
Youssef posted this in #help-forum
YoussefOP
I want to change the page URL without an actual refresh depending on my component's state
Let's say I have the following code
And I want to set the pathname to
Thanks in Advance.
Let's say I have the following code
{formStatus === FormStatus.Login ? (
<Button
variant="text"
onClick={() => setFormStatus(FormStatus.SignUp)}
>
Sign Up
</Button>
) : (
<Button
variant="text"
onClick={() => setFormStatus(FormStatus.Login)}
>
Login
</Button>
)}And I want to set the pathname to
formStatus when button is clickedThanks in Advance.
2 Replies
navigating with router can soft navigate to a query param without any loss of state.