小编Ami*_*min的帖子

在 params 中传递函数时,在导航状态中发现不可序列化的值

我有两个屏幕:

屏幕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)

reactjs react-native react-navigation

23
推荐指数
1
解决办法
6万
查看次数

标签 统计

react-native ×1

react-navigation ×1

reactjs ×1