【发布时间】:2019-10-29 05:02:26
【问题描述】:
我有一个新闻模块,可以从链接中获取文章并以某种状态传播它们:
import React, { Component } from 'react'
import axios from 'axios'
import { URL } from '../../../config'
class NewsList extends Component {
state = {
items: [],
start: this.props.start,
amount: this.props.amount,
end: this.props.start + this.props.amount
}
componentWillMount() {
axios.get( `${ URL }/articles?_start=${ this.state.start }&end=${ this.state.end }` )
.then( res => {
this.setState( prevState => {
items: [ ...prevState.items, ...res.items ]
} )
} )
}
render() {
return<div>
news
</div>
}
}
export default NewsList
控制台中的错误:
Line 19: Expected an assignment or function call and instead saw an expression no-unused-expressions
所以看起来这是一个简单的错误,它与有此错误的类似问题不同。
【问题讨论】:
标签: reactjs ecmascript-6 expression state variable-assignment