Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 如何在react native中使用swiper_React Native_React Native Swiper - Fatal编程技术网

React native 如何在react native中使用swiper

React native 如何在react native中使用swiper,react-native,react-native-swiper,React Native,React Native Swiper,您好,如何让刷卡器使用Home组件中的数据在Profil组件中工作。我在Home组件中有一个状态,在那里我存储来自Web服务的数据 class Accueil extends React.Component { constructor(props) { super(props); this.state = { refreshing: false, latitude:null, longitude:null, dataSourc

您好,如何让刷卡器使用
Home
组件中的数据在
Profil
组件中工作。我在
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>
    )
  }
}
类Accueil扩展了React.Component{
建造师(道具){
超级(道具);
此.state={
刷新:错,
纬度:空,
经度:空,
数据源:[],
错误:null,
appState:appState.currentState,
当前索引:0,
}
this.displayPosition=this.displayPosition.bind(this);
}
getData(){
获取(“SomeURL”)
.then(res=>res.json())
。然后(结果=>{
返回(
这是我的国家({
数据源:结果
}));
})
.catch(错误=>{
控制台错误(错误)
})
}
render(){
返回(
item.MembreId}
renderItem={(项目)=>}
numColumns={numColumns}
刷新={this.state.refreshing}
onRefresh={this.handleRefresh}/>
)
}
}

如何在
Profil
组件中使用
this.state.dataSource
,以
.map
用数据映射开关?

要将值从一个组件传递到另一个组件,可以使用以下代码-

this.props.navigation.navigate('<Your Screen Name>', {
    dataSource: this.state.dataSource
});
通过访问来使用它 this.props.navigation.state.params.dataSource直接将此变量保存到另一个变量中,如上文和 和你的刷子一起使用


我希望这能有所帮助,谢谢:)

将值传递给配置文件组件时,您是否遇到问题??'是的,我可以';无法在Profil Component中传递整个数据源,但是,您必须声明您的
displayPosition
方法。不,我已经声明了displayPosition,但我没有在这里编写它,因为否则会太长,我可以在
Home
Component中的任何地方添加这个吗?profile和Home都是不同的屏幕,或者您在主屏幕中调用profile??它们是不同的屏幕。当我点击
Home
组件中的配置文件时,它会将我发送到
UserProfil
ok然后。。。。点击主屏幕上的press in,您必须提供我的第一个代码,然后在另一个屏幕上,即profile屏幕,您必须使用我的第二个代码@SauceCurryI访问数据源。当我尝试控制台log
tempDataSource
var tempDataSource = [...this.props.navigation.state.params.dataSource]