帮助解决问题。
我正在尝试显示对象的元素state
:
class App extends Component {
state = {
arr: ['one', 'two', 'three']
}
render() {
return (
<div>
{ this.state.arr.map((item, index) => {
<div></div>
})}
</div>
)}
}
export default App;
我得到一个错误:
Expected an assignment or function call and instead saw an
expression no-unused-expressions.
Search for the keywords to learn more about each error.
您忘记添加
return
是因为map 方法应该返回一个新数组: