I have a very simple scenario in which I need to redirect to an external domain in react something like this on change of a switch:
handleSwitch={() => {
location.href = 'https://www.google.com/'; // oldAppUrl;
// window.open(oldAppUrl, '_href')
}}
However, this is not working. What am I missing?
>Solution :
Try like this:
window.location.href = 'https://www.google.com/';
and this should work too, using it in an app:
window.location = 'https://www.google.com/';
If none of these two works it means your handleSwitch function is probably not called, then you should show us some more code to help with the solving.