问题描述
我有这样的状态
constructor(props) {
super(props);
this.state = {
activeRegion: listProvince,listProvince: [],listCity: [],listRegion: [],}
}
以及如何按其他状态使用状态?
所以我将在平面列表中使用的数据基于activeRegion
当activeRegion中的值为ListCity时 列表中使用的数据是this.state.listcity
以此类推
<FlatList
data={this.state.{this.state.activeregion}}
renderItem={({ item }) => (this.renderItem())
/>
如何实现这个目标?
解决方法
与您的操作保持一致的最简单答案是使用括号符号location / {
proxy_pass http://${remote_server}/;
}
this.state.{this.state.activeregion}
这不是有效的JavaScript语法,请如下更新:
this.state[this.state.activeregion]