Skip to main content
update explanation
Source Link

###ES6 arrow function Nice work usingutilizing functional programming (i.e. .map()) and the arrow function. One improvement here is that there isn't much of a need for a code block (i.e. { ....}) and return statement. So the callback to .map() in the render method can be reduced to a single line like below:

render() {    
    return <ul> {
        this.state.comments.map((comment) => <li>{comment.body}—{comment.author}</li>)
    }</ul>;  
}

###jQuery - just for AJAX requests? It appears that the only jQuery functionality used is its AJAX wrapper (i.e. $.ajax()). If that is all jQuery is used for, consider using a different technique like the fetch API (read this article for more info).

componentDidMount() {  
    fetch(JSON_URL)
    .then(response => response.json())
    .then(data => this.setState({comments: data.comments}));    

See this plunker for a demonstration.

##Update It has been mentioned that the fetch API has no support for aborting the request. If that is desired, there are other alternatives like Superagent (recommended by you might not need jQuery). See this updated plunker for an example of using superagent with its abort method in the componentWillUnmount method.

###ES6 arrow function Nice work using functional programming (i.e. .map()) and the arrow function. One improvement here is that there isn't much of a need for a code block (i.e. { ....}) and return statement. So the render method can be reduced like below:

render() {    
    return <ul> {
        this.state.comments.map((comment) => <li>{comment.body}—{comment.author}</li>)
    }</ul>;  
}

###jQuery - just for AJAX requests? It appears that the only jQuery functionality used is its AJAX wrapper (i.e. $.ajax()). If that is all jQuery is used for, consider using a different technique like the fetch API (read this article for more info).

componentDidMount() {  
    fetch(JSON_URL)
    .then(response => response.json())
    .then(data => this.setState({comments: data.comments}));    

See this plunker for a demonstration.

##Update It has been mentioned that the fetch API has no support for aborting the request. If that is desired, there are other alternatives like Superagent (recommended by you might not need jQuery). See this updated plunker for an example of using superagent with its abort method in the componentWillUnmount method.

###ES6 arrow function Nice work utilizing functional programming (i.e. .map()) and the arrow function. One improvement here is that there isn't much of a need for a code block (i.e. { ....}) and return statement. So the callback to .map() in the render method can be reduced to a single line like below:

render() {    
    return <ul> {
        this.state.comments.map((comment) => <li>{comment.body}—{comment.author}</li>)
    }</ul>;  
}

###jQuery - just for AJAX requests? It appears that the only jQuery functionality used is its AJAX wrapper (i.e. $.ajax()). If that is all jQuery is used for, consider using a different technique like the fetch API (read this article for more info).

componentDidMount() {  
    fetch(JSON_URL)
    .then(response => response.json())
    .then(data => this.setState({comments: data.comments}));    

See this plunker for a demonstration.

##Update It has been mentioned that the fetch API has no support for aborting the request. If that is desired, there are other alternatives like Superagent (recommended by you might not need jQuery). See this updated plunker for an example of using superagent with its abort method in the componentWillUnmount method.

update explanation
Source Link

###ES6 arrow function Nice work using functional programming (i.e. .map()) and the arrow function. One improvement here is that there isn't much of a need for a code block (i.e. { ....}) and return statement. So the render method can be reduced like below:

render() {    
    return <ul> {
        this.state.comments.map((comment) => <li>{comment.body}—{comment.author}</li>)
    }</ul>;  
}

###jQuery - just for AJAX requests? It appears that the only jQuery functionality used is its AJAX wrapper (i.e. $.ajax()). If that is all jQuery is used for, consider using a different technique like the fetch API (read this article for more info).

componentDidMount() {  
    fetch(JSON_URL)
    .then(response => response.json())
    .then(data => this.setState({comments: data.comments}));    

See this plunker for a demonstration.

##Update It has been mentioned that the fetch API has no support for aborting the request. If that is desired, there are other alternatives like Superagent (recommended by you might not need jQuery). See this updated plunker for an example of using superagent with its abort method in the componentWillUnmount method.

###ES6 arrow function Nice work using functional programming (i.e. .map()) and the arrow function. One improvement here is that there isn't much of a need for a block and return statement. So the render method can be reduced like below:

render() {    
    return <ul> {
        this.state.comments.map((comment) => <li>{comment.body}—{comment.author}</li>)
    }</ul>;  
}

###jQuery - just for AJAX requests? It appears that the only jQuery functionality used is its AJAX wrapper (i.e. $.ajax()). If that is all jQuery is used for, consider using a different technique like the fetch API (read this article for more info).

componentDidMount() {  
    fetch(JSON_URL)
    .then(response => response.json())
    .then(data => this.setState({comments: data.comments}));    

See this plunker for a demonstration.

##Update It has been mentioned that the fetch API has no support for aborting the request. If that is desired, there are other alternatives like Superagent (recommended by you might not need jQuery). See this updated plunker for an example of using superagent with its abort method in the componentWillUnmount method.

###ES6 arrow function Nice work using functional programming (i.e. .map()) and the arrow function. One improvement here is that there isn't much of a need for a code block (i.e. { ....}) and return statement. So the render method can be reduced like below:

render() {    
    return <ul> {
        this.state.comments.map((comment) => <li>{comment.body}—{comment.author}</li>)
    }</ul>;  
}

###jQuery - just for AJAX requests? It appears that the only jQuery functionality used is its AJAX wrapper (i.e. $.ajax()). If that is all jQuery is used for, consider using a different technique like the fetch API (read this article for more info).

componentDidMount() {  
    fetch(JSON_URL)
    .then(response => response.json())
    .then(data => this.setState({comments: data.comments}));    

See this plunker for a demonstration.

##Update It has been mentioned that the fetch API has no support for aborting the request. If that is desired, there are other alternatives like Superagent (recommended by you might not need jQuery). See this updated plunker for an example of using superagent with its abort method in the componentWillUnmount method.

add example with superagent
Source Link

###ES6 arrow function Nice work using functional programming (i.e. .map()) and the arrow function. One improvement here is that there isn't much of a need for a block and return statement. So the render method can be reduced like below:

render() {    
    return <ul> {
        this.state.comments.map((comment) => <li>{comment.body}—{comment.author}</li>)
    }</ul>;  
}

###jQuery - just for AJAX requests? It appears that the only jQuery functionality used is its AJAX wrapper (i.e. $.ajax()). If that is all jQuery is used for, consider using a different technique like the fetch API (read this article for more info).

componentDidMount() {  
    fetch(JSON_URL)
    .then(response => response.json())
    .then(data => this.setState({comments: data.comments}));    

See this plunker for a demonstration.

##Update It has been mentioned that the fetch API has no support for aborting the request. If that is desired, there are other alternatives like Superagent (recommended by you might not need jQuery). See this updated plunker for an example of using superagent with its abort method in the componentWillUnmount method.

###ES6 arrow function Nice work using functional programming (i.e. .map()) and the arrow function. One improvement here is that there isn't much of a need for a block and return statement. So the render method can be reduced like below:

render() {    
    return <ul> {
        this.state.comments.map((comment) => <li>{comment.body}—{comment.author}</li>)
    }</ul>;  
}

###jQuery - just for AJAX requests? It appears that the only jQuery functionality used is its AJAX wrapper (i.e. $.ajax()). If that is all jQuery is used for, consider using a different technique like the fetch API (read this article for more info).

componentDidMount() {  
    fetch(JSON_URL)
    .then(response => response.json())
    .then(data => this.setState({comments: data.comments}));    

See this plunker for a demonstration.

##Update It has been mentioned that the fetch API has no support for aborting the request. If that is desired, there are other alternatives like Superagent (recommended by you might not need jQuery)

###ES6 arrow function Nice work using functional programming (i.e. .map()) and the arrow function. One improvement here is that there isn't much of a need for a block and return statement. So the render method can be reduced like below:

render() {    
    return <ul> {
        this.state.comments.map((comment) => <li>{comment.body}—{comment.author}</li>)
    }</ul>;  
}

###jQuery - just for AJAX requests? It appears that the only jQuery functionality used is its AJAX wrapper (i.e. $.ajax()). If that is all jQuery is used for, consider using a different technique like the fetch API (read this article for more info).

componentDidMount() {  
    fetch(JSON_URL)
    .then(response => response.json())
    .then(data => this.setState({comments: data.comments}));    

See this plunker for a demonstration.

##Update It has been mentioned that the fetch API has no support for aborting the request. If that is desired, there are other alternatives like Superagent (recommended by you might not need jQuery). See this updated plunker for an example of using superagent with its abort method in the componentWillUnmount method.

mention superagent
Source Link
Loading
use arrow functions in promise callbacks
Source Link
Loading
update wording
Source Link
Loading
add link to MDN for fetch API
Source Link
Loading
Source Link
Loading