const myRef = useRef(null); const clickElement = (ref) => { ref.current.dispatchEvent( new MouseEvent('click', { view: window, bubbles: true, cancelable: true, buttons: 1, }), ); };