Skip to content

Commit

Permalink
revert: back to ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
althafdaa committed Aug 18, 2024
1 parent 4d5bf65 commit 44cff85
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions src/pages/[circleSlug]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import EachPageLayout from '@/components/general/EachPageLayout';
import {
// getCircleBySlugOptions,
getCircleBySlugOptions,
useGetCircleBySlug,
} from '@/hooks/circle/useGetCircleBySlug';
import { prettifyError } from '@/utils/helper';
// import { dehydrate, QueryClient } from '@tanstack/react-query';
// import { GetServerSidePropsContext } from 'next';
import { dehydrate, QueryClient } from '@tanstack/react-query';
import { GetServerSidePropsContext } from 'next';
import SectionPartitionWrapper from '@/components/circle/detail-page/SectionPartitionWrapper';
import GeneralInfoSection from '@/components/circle/detail-page/GeneralInfoSection';
import FandomWorkTypeSection from '@/components/circle/detail-page/FandomWorkTypeSection';
Expand All @@ -16,35 +16,31 @@ import ProductSection from '@/components/circle/detail-page/ProductSection';
import { Fragment } from 'react';
import { NextSeo } from 'next-seo';

// export const getServerSideProps = async (c: GetServerSidePropsContext) => {
// const circleSlug = c.query.circleSlug as string;
// const queryClient = new QueryClient();
export const getServerSideProps = async (c: GetServerSidePropsContext) => {
const circleSlug = c.query.circleSlug as string;
const queryClient = new QueryClient();

// try {
// await queryClient.fetchQuery(
// getCircleBySlugOptions(c, circleSlug, { retry: 0, throwOnError: true }),
// );
// } catch (error) {
// return {
// notFound: true,
// };
// }
try {
await queryClient.fetchQuery(
getCircleBySlugOptions(c, circleSlug, { retry: 0, throwOnError: true }),
);
} catch (error) {
return {
notFound: true,
};
}

// const dehydratedState = dehydrate(queryClient);
const dehydratedState = dehydrate(queryClient);

// return {
// props: {
// dehydratedState,
// },
// };
// };
return {
props: {
dehydratedState,
},
};
};

function CirclePage() {
const { error, isPending, data } = useGetCircleBySlug({
options: {
refetchOnMount: true,
},
});
const { error, isPending, data } = useGetCircleBySlug();

const Content = () => {
if (error) {
Expand Down

0 comments on commit 44cff85

Please sign in to comment.