import React, { useEffect } from 'react'; import { StyleSheet, Text, View, TextInput } from 'react-native'; import { sqlite_exec_query } from '../db/query'; import DepenseListEntry from './depense_list_entry'; function DepensesList(props) { const [depenses, onGetDepenses] = React.useState([]); useEffect( () => { sqlite_exec_query(`create table if not exists expense (id integer primary key not null, value real, description text, date integer);`,(res)=>{ sqlite_exec_query("select * from expense order by date desc", (res) => { onGetDepenses(res.rows._array); }); }); }); let content = [] if(depenses.length > 0) { // get latest and oldest depense let latest_depense = depenses[0]; let oldest_depense = depenses[depenses.length - 1] } depenses .forEach( function(depense){ content.push( ) }); return( {content} ) } const depense_list_style = StyleSheet.create({ depense_list_entry: { display: "flex", flexDirection: "row", justifyContent: "space-between", // flex: 1, // backgroundColor: '#00FF00', // alignItems: 'center', // justifyContent: 'center', } }); export default DepensesList