import { StyleSheet, FlatList, Text } from 'react-native' import { useState, useEffect } from 'react' import Note from './Note' import Menu from './Menu' const List = ({ session, setSession, showError, setEdit }) => { const [list, setList] = useState() const [loading, setLoading] = useState(true) const fetchNotes = async () => { setLoading(true) try { const response = await fetch('https://apps.pruss.it/api/notes', { 'Cookie': session.cookies } ) const data = await response.json() setList(data) } catch(e) { showError('Error while fetching notes') } setLoading(false) } useEffect(() => { setLoading(true) fetchNotes() }, []) return ( <>
{ loading || list === undefined ?