Commit 4cd275f1 authored by Choi Ga Young's avatar Choi Ga Young
Browse files

focus 에러 해결

parent 7d2182de
import React, { useState, useEffect } from 'react';
import Calendar from './components/Calendar';
import calApi from './db/calendarInfo.api';
import { useFocusEffect } from '@react-navigation/native';
import { useIsFocused } from '@react-navigation/native';
const Montly = ({ navigation }) => {
const isFocused = useIsFocused();
const date = new Date();
const [year, setYear] = useState(date.getFullYear());
const [month, setMonth] = useState(date.getMonth());
......@@ -23,11 +25,10 @@ const Montly = ({ navigation }) => {
getData()
}, [month])
useFocusEffect(
React.useCallback(() => {
useEffect(() => {
getData()
}, [])
);
}, [isFocused])
return (
<Calendar navigation={navigation} MData={totalM} year={year} setYear={setYear} month={month} setMonth={setMonth} todayM={todayM} todayY={todayY} />
)
......
......@@ -14,7 +14,7 @@ const getFullData = async ({ year, month }) => {
db.transaction(async (tx) => {
const [txn, results] = await tx.executeSql(`SELECT date, type_id, sum(price) as total from money where date BETWEEN "${getDateStr(thisFirst)}" and "${getDateStr(thisLast)}" group by date, type_id`);
const temp = [];
if (results.rows.length != 0) {
if (results.rows.length !== 0) {
if (results.rows.item(0).type_id === 1) {
temp.push({ date: results.rows.item(0).date, type: { 'input': results.rows.item(0).total } })
}
......
......@@ -35,8 +35,6 @@ const outMoney = async ({ year, month }) => {
}
const yearMoney = async ({ year }) => {
const yearFirst = new Date(year, 0, 1);
const yearLast = new Date(year, 12, 0);
const db = await getDb();
return new Promise((res, rej) => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment