Navigate to new url from SPFX in Sharepoint online

New Contributor
I have a dropdown in SPFX webpart in sharepoint online. In that dropdown, onchange, I am constructing a url with # tag. E.x. https://sharepointonine/default.aspx#2349-234234-23434

I need to navigate to this new url. I am not sure how to accomplish things. I have tried:

window.location = url //Gives error that string is not assignable to Location
window.location.href= url//does not reload the page, "_self")//does not reload the page
window.location.assign(url);//does not reload the page
 window.location.replace(url);//does not reload the page

Any help?

1 Reply

Using query parameters instead of url fragment has resolved the issue . With that , window.location.href will also work