Reputation: 45
I am using the React material design library. I added an onClick
listener to <link>
, but the function is called on a page load. Why is this happening?
Here is my code :
<Link onClick={openBrowserWindow('http://www.stackoverflow.com')}/>
const openBrowserWindow = (url) =>{
fin.desktop.system.openUrlWithBrowser(url);
}`
Upvotes: 2
Views: 151
Reputation: 1570
Because of the way you put the onCLick method, the function call it itself
try put the call into a function
<Link onClick = {()=>openBrowserWindow('stackoverflow.com')}/>
Upvotes: 2