我有两个屏幕:
屏幕A
import React, { useState } from "react";
import { Text, View, Button } from "react-native";
const ViewA = ({ navigation }) => {
const [val, setVal] = useState(null);
const [val2, setVal2] = useState(null);
const callBack = (value1,value2) => {
setVal(value1);
setVal2(value2);
};
const onNextPress = () => {
navigation.navigate("Second Screen", { callBack: callBack });
};
return (
<View>
<Text>{val}{val2}</Text>
<Button title="Next" onPress={onNextPress} />
</View>
);
};
export default ViewA;
Run Code Online (Sandbox Code Playgroud)
屏幕B
import React from "react";
import { View, Button …Run Code Online (Sandbox Code Playgroud)