ashutosh kumar
ashutosh kumar

Reputation: 45

React material design function call automatically on page onload instead on onclick

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

Answers (1)

Maxime Girou
Maxime Girou

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

Related Questions