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

focus 에러 해결

parent 7d2182de
...@@ -56,7 +56,7 @@ const Analy = () => { ...@@ -56,7 +56,7 @@ const Analy = () => {
calPercentage() calPercentage()
}, []) }, [])
); );
useEffect(() => { useEffect(() => {
setResDataM([]) setResDataM([])
calPercentage() calPercentage()
......
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import Calendar from './components/Calendar'; import Calendar from './components/Calendar';
import calApi from './db/calendarInfo.api'; import calApi from './db/calendarInfo.api';
import { useFocusEffect } from '@react-navigation/native'; import { useIsFocused } from '@react-navigation/native';
const Montly = ({ navigation }) => { const Montly = ({ navigation }) => {
const isFocused = useIsFocused();
const date = new Date(); const date = new Date();
const [year, setYear] = useState(date.getFullYear()); const [year, setYear] = useState(date.getFullYear());
const [month, setMonth] = useState(date.getMonth()); const [month, setMonth] = useState(date.getMonth());
...@@ -23,11 +25,10 @@ const Montly = ({ navigation }) => { ...@@ -23,11 +25,10 @@ const Montly = ({ navigation }) => {
getData() getData()
}, [month]) }, [month])
useFocusEffect( useEffect(() => {
React.useCallback(() => { getData()
getData() }, [isFocused])
}, [])
);
return ( return (
<Calendar navigation={navigation} MData={totalM} year={year} setYear={setYear} month={month} setMonth={setMonth} todayM={todayM} todayY={todayY} /> <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 }) => { ...@@ -14,7 +14,7 @@ const getFullData = async ({ year, month }) => {
db.transaction(async (tx) => { 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 [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 = []; const temp = [];
if (results.rows.length != 0) { if (results.rows.length !== 0) {
if (results.rows.item(0).type_id === 1) { if (results.rows.item(0).type_id === 1) {
temp.push({ date: results.rows.item(0).date, type: { 'input': results.rows.item(0).total } }) temp.push({ date: results.rows.item(0).date, type: { 'input': results.rows.item(0).total } })
} }
......
...@@ -35,9 +35,7 @@ const outMoney = async ({ year, month }) => { ...@@ -35,9 +35,7 @@ const outMoney = async ({ year, month }) => {
} }
const yearMoney = async ({ year }) => { const yearMoney = async ({ year }) => {
const yearFirst = new Date(year, 0, 1); const db = await getDb();
const yearLast = new Date(year, 12, 0);
const db = await getDb();
return new Promise((res, rej) => { return new Promise((res, rej) => {
db.transaction(async (tx) => { db.transaction(async (tx) => {
......
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