I am trying implement a function that takes url and navigates to the provided URL, from typescript function I am trying create a link object dynamically and simulate click event on the dynamic link? I have following code to create the link element not sure hot simulate the click
const openExternalLink = (linkAddress) => {
const linkElement = React.createElement('a', {href: linkAddress},linkAddress);
linkElement.click(); <-- ERROR
};
The above code not compiling following is the error message:
Property 'click' does not exist on type 'DetailedReactHTMLElement<{ href: string; }, HTMLElement>'.ts(2339)
Any idea how to simulate the click on a dynamically created UI element?