我想在路由参数中设置一个默认值,如果没有从我们以前做过的其他屏幕发送任何内容
let phot0 = this.props.navigation.getParam("photo","empty");
Run Code Online (Sandbox Code Playgroud)
在 react Navigation 5.x 中做什么我的代码是..(第 5 行的困难)
import React from "react";
import { StyleSheet, Text, View, Image, Button } from "react-native";
export default function Home({ route, navigation }) {
const { photo } = route.params;
return (
<View style={styles.container}>
<Image
resizeMode="center"
style={styles.imageHolder}
source={photo === "empty" ? require("../assets/email.png") : photo}
/>
<Button
title="take photo"
style={styles.button}
onPress={() => navigation.navigate("Camera")}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center", …Run Code Online (Sandbox Code Playgroud)