import * as React from "react"; import { View, Text, TextInput, Switch } from "react-native"; import styles from "../../styles"; import Background from "../../Components/Background/Background"; import { SafeAreaView } from "react-native-safe-area-context"; import { useState } from "react"; import { TouchableOpacity } from "react-native"; import { RootDrawerParamList } from "../../Interfaces/Interfaces"; import { useNavigation } from "@react-navigation/native"; import { useMutation, useQueryClient } from "react-query"; import { AddNote } from "../../Components/Api/Api"; export default function NewNote() { const [note, setNote] = useState({ title: "", content: "", public: false, }); const navigation = useNavigation(); const queryClient = useQueryClient(); const mutation = useMutation({ mutationFn: AddNote, onSuccess: () => { queryClient.invalidateQueries("notes"); }, }); return ( New Note { setNote({ ...note, title: text }); }} maxLength={20} /> { await setNote({ ...note, content: text }); }} /> setNote({ ...note, public: !note.public })} value={note.public} /> Public? { try { await mutation.mutate({ title: note.title, content: note.content, public: note.public, }); navigation.navigate("Home"); } catch (error) {} console.log(note.content); }} > SAVE { navigation.navigate("Home"); }} > CANCEL ); }