Hello everyone, given a condition, if it is true, how is it possible to load a specific url?
const completarRegistro =()=>{
if(codigo===codigo_agregado){
/ *
Here I must load a specific url.
In the buttons href = "/ url" is used
And what can I use here? * /
}
else{
setCount(6);
}
}
Thanks in advance.
Pretty confusing what you are asking, but you can use NavContext to navigate within code.
const navContext = React.useContext(NavContext); // import NavContext
navContext.navigate('/your-url');
Or you would have to have
const [url, setUrl] = React.useState('/initial-url');
function changeUrl() {
setUrl('/my-new-url');
}
<IonButton routerLink={url}>Navigate</IonButton> // use routerLink in Ionic-React, not href IIRC
1 Like