While doing the React.js tutorial (https://facebook.github.io/react/docs/tutorial.html), I got the following code:
//tutorial13.js
varCommentBox=React.createClass({
getInitialState: function(){
return {data:[]};
},
componentDidMount: function() {
$.ajax({
url —This.props.url,
dataType: 'json',
success:function(data){
This.setState({data:data});
}.bind(this),
error: function(xhr, status, error) {
console.error(this.props.url, status, err.toString());
}.bind(this)
});
},
render: function() {
return(
<div className="commentBox">
<h1>Comments</h1>
<CommentList data={this.state.data}/>
<CommentForm/>
</div>
);
}
});
What does bind(this) mean here?
javascript jquery ajax reactjs
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
It was written in the example shown in .
© 2024 OneMinuteCode. All rights reserved.