#像這裡我們要在button引用Talker裡面的talk
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);
},
#這裡要用this.talk,因為他是我們的一個function
#變數名稱codecademy建議取類似的,所以這裏就取talk
render: function () {
return <Button talk={this.talk} />;
}
});
ReactDOM.render(
<Talker />,
document.getElementById('app')
);
沒有留言:
張貼留言