My simple react code is:
main.js:
var ReactDom = require('react-dom');
var Main = React.createClass({
render: function(){
return(
<div>
<a onClick={alert("hello world")} >hello</a>
</div>
)
}
});
in console there were an error :
TypeError: listener must be a function
ERROR:
while running this code, I am getting that alert function instead of that this should be on click function.
Note: I am using flux structure but there were no data populating in given file.
Thanks in advance
you should wrap the alert in a function you can use fat arrows to do the job
<a onClick={() => alert("hello world")} >hello</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With