Skip to content

Commit

Permalink
feat: 앱 로딩 초기에 데이터를 가져오도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
eunbae0 committed Jan 31, 2024
1 parent aa51f06 commit d297223
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
5 changes: 1 addition & 4 deletions src/components/containers/MainContainer/MainContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import { useCallback } from 'react';
import MainPage from '../../pages/MainPage';
import TimelineView from '../../templates/TimelineView';
import useIsMainStore from '../../../store/isMain';
import APIService from '../../../api';

const MainContainer = () => {
const { isMain, setTimelinePage } = useIsMainStore();

const setTimelineView = useCallback(async () => {
const setTimelineView = useCallback(() => {
setTimelinePage();
// eslint-disable-next-line react-hooks/exhaustive-deps
const recapInfo = await APIService.getLibraryHistories();
console.log(recapInfo);
}, []);

return isMain ? (
Expand Down
24 changes: 12 additions & 12 deletions src/hooks/useInitApp.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useEffect } from 'react';
import uoslifeBridge from '../bridge';
import useUserStore from '../store/user';
// import APIService from '../api/service';
// import useRecapInfoStore from '../store/recapInfo';
import APIService from '../api/service';
import useRecapInfoStore from '../store/recapInfo';

const useInitApp = () => {
const { setUser, setDefaultUser } = useUserStore();
// const { setRecapInfo } = useRecapInfoStore();
const { setRecapInfo } = useRecapInfoStore();

const handleUserInfo = async () => {
try {
Expand All @@ -16,19 +16,19 @@ const useInitApp = () => {
setDefaultUser();
}
};
// const handleRecapInfo = async () => {
// try {
// const recapInfo = await APIService.getLibraryHistories();
// setRecapInfo(recapInfo);
// } catch (e) {
// console.error(e);
// }
// };
const handleRecapInfo = async () => {
try {
const recapInfo = await APIService.getLibraryHistories();
setRecapInfo(recapInfo);
} catch (e) {
console.error(e);
}
};

useEffect(() => {
(async () => {
handleUserInfo();
// handleRecapInfo();
handleRecapInfo();
})();
}, []);
};
Expand Down

0 comments on commit d297223

Please sign in to comment.