如何通过javascript引用react-native中的getNext道具?

时间:2017-05-16 17:45:07

标签: javascript reactjs react-native

我有一个类似的cokebase,我想让地图中的回调渲染函数引用getNext道具,我该怎么办?

const render = ({ photoURL }) => {
  return(
    <Image key={photoURL} resizeMode="contain" style={{flex: 1}} source={{uri: photoURL}}>
      <View style={{ flex: 1, marginLeft: 10, marginBottom: 20, flexDirection: "row", alignItems: "flex-end", justifyContent: "center"}}>
        <Button icon={{ name: "heart", type: "evilicon", color: "#ff0000", size: 70 }} backgroundColor="transparent" onPress={getNext} />
        <Button icon={{ name: "close-o", type: "evilicon", color: "#ff0000", size: 70 }} backgroundColor="transparent" onPress={getNext} />
      </View>
    </Image>
  )
}
//const { image, view } = styles

const Picture = ({ PHOTO_URLS, getNext}) => {

  return(
    <View style={{flex: 1}}>
      <Carousel delay={2000} style={{ flex: 1, backgroundColor: "#ff1493" }} pageInfo autoplay={false} onAnimateNextPage={(p) => console.log(p)} >
        {PHOTO_URLS.map(render)}
      </Carousel> 
    </View>
  )
}

export { Picture } 

1 个答案:

答案 0 :(得分:0)

您可以调用另一个将required parameters传递给它的函数。像下面的东西

 { PHOTO_URLS.map((arg) => render(arg, getNext)) }