Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 我正在尝试将函数从app.js传递到Deatails屏幕。但我一直收到这个错误(在导航中发现了不可序列化的值)_Reactjs_React Native_React Hooks_React Navigation_React Native Flatlist - Fatal编程技术网

Reactjs 我正在尝试将函数从app.js传递到Deatails屏幕。但我一直收到这个错误(在导航中发现了不可序列化的值)

Reactjs 我正在尝试将函数从app.js传递到Deatails屏幕。但我一直收到这个错误(在导航中发现了不可序列化的值),reactjs,react-native,react-hooks,react-navigation,react-native-flatlist,Reactjs,React Native,React Hooks,React Navigation,React Native Flatlist,我在详细信息屏幕中有textinput,当用户单击该按钮时,我想添加用户在第一页的flatlist中输入的文本 这是我的app.js function HomeScreen({ navigation }) { const [Note, setNote] = useState([]); const addNotes = (note) => { note.id == note.length + 1; setNote([...Note, note]); }; ret

我在详细信息屏幕中有textinput,当用户单击该按钮时,我想添加用户在第一页的flatlist中输入的文本

这是我的app.js

function HomeScreen({ navigation }) {
  const [Note, setNote] = useState([]);
  const addNotes = (note) => {
    note.id == note.length + 1;
    setNote([...Note, note]);
  };

return (
    <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
      <Text>Home Screen</Text>
      <Button
        title="Go to Details"
        onPress={() =>
          navigation.navigate("Details", {
            addNotes,
          })
        }
  />
  <View>
    <FlatList
      data={Note}
      renderItem={({ item }) => {
        <Text>{item.Note}</Text>;
      }}
    />
  </View>
</View>
功能主屏幕({navigation}){
const[Note,setNote]=useState([]);
常量添加注释=(注释)=>{
note.id==note.length+1;
设置注释([…注释,注释]);
};
返回(
主屏幕
导航。导航(“详细信息”{
补充说明,
})
}
/>
{
{项目.说明};
}}
/>
)); }

这是我的详细信息屏幕

function DetailsScreen({ route, navigation }) {
  const [notes, setNotes] = useState("");
  function Onadd() {
    route.params.addNotes({ notes });
    navigation.goBack();
  }
  return (
    <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
      <Text>input Screen</Text>
      <View>
        <TextInput value={notes} onChangeText={setNotes} style={styles.input} />
      </View>
      <Text>{notes}</Text>
      <Button title="Go to HomeScreen" onPress={() => Onadd()} />
    </View>
  );
}
函数细节屏幕({route,navigation}){
const[notes,setNotes]=useState(“”);
函数Onadd(){
route.params.addNotes({notes});
navigation.goBack();
}
返回(
输入屏幕
{notes}
Onadd()}/>
);
}

您不能在导航中传递函数,只能传递数据。