不确定为什么会收到此错误:
render() {
14 | let { params } = this.props.match
15 | let country = this.state.countries.find(country => country.cca· === params.id)
> 16 | let countryBorders = country.borders.map(border => this.state.countries.find(country => country.cca3 === border && country))
| ^ 17 |
18 |返回 ( 19 | 19
最佳答案
国家的值(value)是什么?您需要确保您没有尝试访问尚不存在的值的属性。
尝试这样的事情:
countryBorders = country && country.borders.map(border => this.state.countries.find(country => country.cca3 === border && country)) || []
关于javascript - ×类型错误: Cannot read property 'borders' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60513531/