Below method works fine
var DBBox = React.createClass({
loadArticlesFromServer: function() {
$.ajax({
url: this.props.url,
dataType: 'json',
data: {username:data.username,isPublished:data.isPublished, heading:data.heading},
cache: false,
success: function(data) {
this.setState({data: data});
}.bind(this),
error: function(xhr, status, err) {
console.error(this.props.url, status, err.toString());
}.bind(this)
});
},
But if I change method declaration to arrow function on line 2 like this
loadArticlesFromServer: ()=> { //error - Cannot read property 'props' of undefined at line 6
or
loadArticlesFromServer= ()=> { //Syntax error
Am I using arrow function incorrectly or missing something? or is it not supported? I am using chrome and tried enabling harmony flag without any luck.