嗨,如何Profil
使用来自组件的数据让 swiper 在组件中工作Home
。我在组件中有一个状态,Home
我在其中存储来自 Web 服务的数据。
class Accueil extends React.Component {
constructor(props) {
super(props);
this.state = {
refreshing: false,
latitude:null,
longitude:null,
dataSource:[],
error:null,
appState: AppState.currentState,
currentIndex: 0,
}
this.displayPosition = this.displayPosition.bind(this);
}
getData(){
fetch("SomeURL")
.then(res => res.json())
.then(result => {
return(
this.setState({
dataSource: result
}));
})
.catch(error => {
console.error(error)
})
}
render() {
return (
<SafeAreaView style={{ flex:1 }}>
<View style={styles.main_container}>
<FlatList style={styles.flatList}
data={this.state.dataSource}
extraData = {this.state}
keyExtractor={(item, index) => item.MembreId}
renderItem={(item) => <UserItem user={item} displayDetailForUser={this._displayDetailForUser} displaySwipe = {this._displaySwipe}/>}
numColumns={numColumns}
refreshing={this.state.refreshing}
onRefresh={this.handleRefresh} />
</View>
</SafeAreaView>
)
}
}
我如何this.state.dataSource
在Profil
组件中.map
使用数据来刷卡?