I have a horizontal flatlist inside a vertical flatlist and I want data on the inside flatlist to be provided based on which item of the outer flatlist is being rendered
(我在垂直平面清单中有一个水平平面清单,并且我希望根据正在呈现的外部平面清单中的项目来提供内部平面清单中的数据)
This is what I have currently:
(这是我目前拥有的:)
<FlatList style={styles.outerFlatlist} data={this.state.catagories} renderItem={({item, index})=>{ return ( <View> <View> <Text style={styles.catagoryName}> {item.CategoryName} </Text> </View> <View style={styles.innerFlatlist}> <FlatList horizontal={true} data={this.state.product1} renderItem={({item, index})=>{ return ( <View style={styles.productsContainer}> <View style={styles.productImage}> <Image source={{uri:item.productImage}} style={styles.image} resizeMode='contain'> </Image> </View> <View style={styles.productDETAILS}> <Text style={styles.productPrice}>R{item.productPrice} </Text> <Text style={styles.productDescription}> {item.productDecription} </Text> </View> </View> ); }}/> </View> </View> ); }}/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
With the above code, everything works well except that each category displays the same data (this.state.product1), how can I make the data of the inner flatlist be dependant on the which item on the outer flatlist is displayed?
(使用上面的代码,除了每个类别显示相同的数据(this.state.product1)之外,其他所有东西都运行良好,如何使内部平面列表的数据依赖于外部平面列表上显示的项目?)
ask by Proff Mushiana Mulweli translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…