Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] - 여행 계획 상세 페이지 성능 최적화 #453

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="chrome" content="nointentdetection" />

<link rel="preconnect" href="https://maps.googleapis.com" />
<link rel="preconnect" href="https://maps.gstatic.com" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="dns-prefetch" href="https://maps.googleapis.com" />
<link rel="dns-prefetch" href="https://maps.gstatic.com" />
<link rel="dns-prefetch" href="https://fonts.googleapis.com" />

<title>to your route, 투룻</title>
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Libraries } from "@react-google-maps/api";

export const LIBRARIES: Libraries = ["maps", "places", "marker"];
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { Libraries, LoadScript } from "@react-google-maps/api";
import { useJsApiLoader } from "@react-google-maps/api";

interface GoogleMapLoadScriptProps {
libraries: Libraries;
loadingElement?: React.ReactNode;
import { LIBRARIES } from "@components/common/GoogleMapLoadScript/GoogleMapLoadScript.constants";

interface GoogleMapLoadScriptProps extends React.PropsWithChildren {
loadingElement: React.ReactNode;
}

const GoogleMapLoadScript = ({
children,
libraries,
loadingElement,
}: React.PropsWithChildren<GoogleMapLoadScriptProps>) => {
return (
<LoadScript
googleMapsApiKey={process.env.REACT_APP_GOOGLE_MAP_API_KEY ?? ""}
libraries={libraries}
loadingElement={loadingElement}
>
{children}
</LoadScript>
);
const GoogleMapLoadScript = ({ children, loadingElement }: GoogleMapLoadScriptProps) => {
const { isLoaded } = useJsApiLoader({
googleMapsApiKey: process.env.REACT_APP_GOOGLE_MAP_API_KEY ?? "",
libraries: LIBRARIES,
});

return isLoaded ? <>{children}</> : loadingElement;
};

export default GoogleMapLoadScript;
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ const TravelPlansTabContent = ({ places }: { places: TravelPlanPlace[] }) => {

return (
<div>
<GoogleMapLoadScript
loadingElement={<Skeleton width="100%" height="23rem" />}
libraries={["places", "maps"]}
>
<GoogleMapLoadScript loadingElement={<Skeleton width="100%" height="23rem" />}>
<GoogleMapView places={positions} />
</GoogleMapLoadScript>
<S.BoxContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ const TravelPlanEditPage = () => {
</IconButton>
</S.LoadingWrapper>
}
libraries={["places", "maps"]}
>
<Accordion.Root css={S.accordionRootStyle}>
{travelPlanDays.map((travelDay, dayIndex) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ const TravelPlanRegisterPage = () => {
</IconButton>
</S.LoadingWrapper>
}
libraries={["places", "maps"]}
>
<Accordion.Root css={S.accordionRootStyle}>
{travelPlanDays.map((travelDay, dayIndex) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ const TravelogueTabContent = ({ places }: { places: TraveloguePlace[] }) => {

return (
<S.TravelogueTapContentLayout>
<GoogleMapLoadScript
loadingElement={<Skeleton width="100%" height="120px" />}
libraries={["maps"]}
>
<GoogleMapLoadScript loadingElement={<Skeleton width="100%" height="120px" />}>
<GoogleMapView
places={places.map((place) => ({
lat: Number(place.position.lat),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ const TravelogueEditPage = () => {
</IconButton>
</S.LoadingWrapper>
}
libraries={["places", "maps"]}
>
<Accordion.Root css={S.accordionRootStyle}>
{travelogueDays.map((travelogueDay, dayIndex) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
return () => {
saveTransformDetail(null);
};
}, [user?.accessToken, navigate]);

Check warning on line 140 in frontend/src/components/pages/travelogueRegister/TravelogueRegisterPage.tsx

View workflow job for this annotation

GitHub Actions / frontend-ci

React Hook useEffect has a missing dependency: 'saveTransformDetail'. Either include it or remove the dependency array

return (
<>
Expand Down Expand Up @@ -209,7 +209,6 @@
</IconButton>
</S.LoadingWrapper>
}
libraries={["places", "maps"]}
>
<Accordion.Root css={S.accordionRootStyle}>
{travelogueDays.map((travelogueDay, dayIndex) => (
Expand Down
Loading