Fix data persistence issue

Addresses a bug where budget and expense data were not persisting correctly, leading to data loss when navigating between pages.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 06:41:57 +00:00
parent c23f5cddef
commit 16c17f0257
9 changed files with 135 additions and 37 deletions

View File

@@ -37,20 +37,15 @@ const Index = () => {
}
}, [isInitialized, checkWelcomeDialogState]);
// 트랜잭션 변경 시 페이지 새로고침
// 앱이 포커스를 얻었을 때 데이터를 새로고침
useEffect(() => {
const handleTransactionAdded = () => {
console.log('트랜잭션이 추가되었습니다. 페이지를 새로고침합니다.');
// 컨텍스트에서 최신 데이터 가져오기
const handleFocus = () => {
// 이벤트 발생시켜 데이터 새로고침
window.dispatchEvent(new Event('storage'));
};
window.addEventListener('transactionAdded', handleTransactionAdded);
window.addEventListener('budgetDataUpdated', handleTransactionAdded);
return () => {
window.removeEventListener('transactionAdded', handleTransactionAdded);
window.removeEventListener('budgetDataUpdated', handleTransactionAdded);
};
window.addEventListener('focus', handleFocus);
return () => window.removeEventListener('focus', handleFocus);
}, []);
return (