0
I am trying to redirect to an external url ,using the vaiparala function by passing a parameter that I pick up from the click, the path arrives at the function correctly but the redirect does not is done , what I might be doing wrong ?
React.useEffect(() => {
const vaiparala = (caminho) => {
console.log(caminho);
caminho === 'Linkedin' ? (
<Link to={"https://www.linkedin.com/feed/"} />
) : (
history.push(`/${caminho}`)
);
};
const handleClick = (e) => {
const items = document.getElementsByClassName('context-menu-item');
if (items && items.length > 0) {
let count = 0;
for (let i = 0; i < items.length; i++) {
if (items[i].contains(e.target)) {
vaiparala(rotasClick[i]);
count++;
}
}
if (count === 0) {
setActive(false);
}
} else {
setActive(false);
}
};
document.addEventListener('click', handleClick);
return () => {
document.removeEventListener('click', handleClick);
};
}, []);
It worked perfectly, thank you very much !
– Marcelo Ivan