I\'m trying to simulate a .click()
event
on a React element but I can\'t figure out why it is not working (It\'s not reacting when I\'m firing the
Using React useRef Hooks you can trigger a click event on any button like this:
export default const () => {
// Defining the ref constant variable
const inputRef = React.useRef(null);
// example use
const keyboardEvent = () => {
inputRef.current.handleClick(); //Trigger click
}
// registering the ref
return (
console.log('clicked')}>
hello
)
}