Javascript 如何使转盘重定向到选择了相应id的另一个页面

Javascript 如何使转盘重定向到选择了相应id的另一个页面,javascript,reactjs,react-native,react-navigation,carousel,Javascript,Reactjs,React Native,React Navigation,Carousel,我是react native的新手,我正在尝试制作一个旋转木马组件卡,一旦按下,它应该导航到其他页面并从卡阵列发送相应的id 这是我的“.App.js”页面,它工作正常: export default function App() { return ( <NavigationContainer> <Stack.Navigator> <Stack.Screen name='Receita' component={selectTy

我是react native的新手,我正在尝试制作一个旋转木马组件卡,一旦按下,它应该导航到其他页面并从卡阵列发送相应的id

这是我的“.App.js”页面,它工作正常:

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen name='Receita' component={selectType} />
        <Stack.Screen name='Informe os ingredientes' component={findRecipe} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
const carouselItems = [
  {
    id: 1,
    title: "Doce",
    text: "[TEXTO DESCRITIVO]",
    illustration: require('../../assets/sobremesa.jpg'),
  },
  {
    id: 2,
    title: "Salgado",
    text: "[DESCRIÇÃO]",
    illustration: require('../../assets/refeicao.jpg'),
  },
]
这是我想要更新的旋转木马组件,一旦按下它,它会将用户发送到“findRecipe”页面

return (
    <View style={styles.container} >
      <TouchableOpacity onPress={goForward}>
        <Text style={styles.titleText}>Selecione o tipo de receita</Text>
      </TouchableOpacity>
      <Carousel
        layout={"default"}
        ref={ref => carousel = ref}
        data={carouselItems}
        sliderWidth={screenWidth}
        sliderHeight={screenWidth}
        itemWidth={screenWidth - 60}
        renderItem={renderItem}
        onSnapToItem={index => setState({ activeIndex: index })}
        hasParallaxImages={true}
      />
      <Button title='INGREDIENTES' onPress={() => navigation.navigate('Informe os ingredientes')}></Button>
    </View >
  );
返回(
蒂波德雷西塔酒店
转盘=ref}
数据={carouselItems}
滑块宽度={screenWidth}
滑块高度={screenWidth}
itemWidth={screenWidth-60}
renderItem={renderItem}
onSnapToItem={index=>setState({activeIndex:index})}
hasParallaxImages={true}
/>
navigation.navigate('Informe os ingredientes')}>
);
我在按钮组件中找到了一种方法,但我真的需要在旋转木马卡上完成,并发送被按下的相应寄存器的id。
有人能帮忙吗?

示例send正在运行,非常感谢Tuan!
snack.expo.io/KJl_IKU3D–tuan.tran 29分钟前

只需使用button way执行相同的操作,按按钮容器包装您的旋转木马项目,然后使用params carouselItem.id导航。您可以分享一个示例吗?