We need to trigger a function when our website users click on a button (for Mixpanel analytics). Is it a good idea to just update our Gatsby Link components with an onClick handler?
I'm particularly mindful of accessibility issues.
Thanks
// What we currently do
const Component = () => {
return <Link to="/">Home</Link>
}
// What we're thinking of doing
const Component = () => {
const handleClick = (e) => {
e.preventDefault();
triggerFunction();
navigate("/")
}
return <Link to="/" onClick={handleClick}>Home</Link>
}