Put an Event Handler in a Component Class - Who can explain me exactly the reasoning?

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

```

var React = require(‘react’);
var ReactDOM = require(‘react-dom’);
var Button = require(’./Button’);

var Talker = React.createClass({
talk: function () {
for (var speech = ‘’, i = 0; i < 10000; i++) {
speech += 'blah ';
}
alert(speech);
},
render: function () {
return ;
}
});

ReactDOM.render(
,
document.getElementById(‘app’)
);

<do not remove the three backticks above>

I found this solution that works very well in an other post on the forum. But the post says just to add 

talk={this.talk}/>;

to the <Button /> component instance, it doesn't explain why it works. Who could help me with an explanation?!
Why I need to add a property with the name of the function I created on the React.createClass, and the value with the same function?

Cheers!
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.