当我尝试运行此命令时:
const nums = this.props.date.phoneNumbers.map( (num) => {
<span>{ num }<br/></span>
})
我犯了错误:
Expected an assignment or function call and instead saw an expression no-unused-expressions
但是所有工作都没有跨度:
const nums = this.props.date.phoneNumbers.map( (num) => {
console.log(num);
})
我做错了什么?
最佳答案
您需要使用 return
返回打开大括号后的任何值
const nums = this.props.date.phoneNumbers.map( (num) => {
return <span>{ num }<br/></span>
})
关于javascript - 为什么在 React+Redux 中尝试映射数组时出现错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54055485/