Skip to content

Commit

Permalink
refactor: 구글 지도를 로드해주는 페이지와 UI를 렌더링 하는 페이지 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielyoon7 committed Oct 25, 2023
1 parent 2e7257f commit bd646ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
13 changes: 11 additions & 2 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import { Status, Wrapper } from '@googlemaps/react-wrapper';
import Loading from 'components/ui/Loading';

import CarFfeineMap from '@map/CarFfeineMap';
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';

import NotFound from '@ui/NotFound';

const RedirectToGoogleMaps = () => {
const navigate = useNavigate();
useEffect(() => {
navigate('/maps');
}, []);
return <></>;
};

const render = (status: Status) => {
switch (status) {
case Status.LOADING:
return <Loading />;
case Status.FAILURE:
return <NotFound />;
case Status.SUCCESS:
return <CarFfeineMap />;
return <RedirectToGoogleMaps />;
}
};

Expand Down
10 changes: 8 additions & 2 deletions frontend/src/router/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { lazy } from 'react';
import { createBrowserRouter } from 'react-router-dom';

import GoogleLogin from '@components/login-page/GoogleLogin';

import NotFound from '@ui/NotFound';

import App from '../App';

const GoogleLogin = lazy(() => import('@components/login-page/GoogleLogin'));
const CarFfeineMap = lazy(() => import('@map/CarFfeineMap'));

export const router = createBrowserRouter([
{
path: '/google',
Expand All @@ -16,4 +18,8 @@ export const router = createBrowserRouter([
element: <App />,
errorElement: <NotFound />,
},
{
path: '/maps',
element: <CarFfeineMap />,
},
]);

0 comments on commit bd646ad

Please sign in to comment.