如何使用导航(版本5)将捕获的图像从本机相机传递到另一个屏幕

时间:2020-08-26 07:28:45

标签: react-native react-native-navigation react-native-image

我遵循了它起作用的文档,但是使用捕获后返回的图像数据不会出现在新屏幕上。我已经搜索过但没有任何导航图像数据的解决方案。

this is the code for passing the image data to the next screen, alongside a test

the screen for receiving the captured image

receiving the captured image in an image component

passing image data to state(path and pathBase64)

3 个答案:

答案 0 :(得分:0)

使用此代码导航到屏幕,此处imageFile是从相机捕获后存储图像的状态。

props.navigation.navigate("navigation_route",{image: imageFile})

然后,使用此代码在另一个屏幕上获取图像。

let image = props.navigation.getParam('image')

答案 1 :(得分:0)

要在下一个屏幕中接收图像,请使用以下代码

let image = props.route.params.image

答案 2 :(得分:0)

屏幕发送图像 函数:navigation.navigate('RouteName',{imageTobeTransferred:
state.imageInBase64})

接收屏幕。 const {imageTobeTransferred} = route.params; 返回( <图片样式= {{......} source = {{uri:data:image/jpeg;base64, ${imageTobeTransferred}}} /> )