I'm using window.location.href to fetch url from the browser. As soon as the specified "url" is reached, it should call the fuction abc(), somewhat like below:
if (window.location.href === "url") {
abc(); //calls the function abc
}
function abc () {
//code..
}
How do I do it the right way?
you can use this
useEffect(() => {
if(window.location.href === 'url'){
abc()
}
},[window.location.href])