mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
(nextjs) fixed getServerSideProps typings
This commit is contained in:
parent
2d9d88f1a1
commit
d9127e5b7c
4 changed files with 15 additions and 16 deletions
|
@ -13,14 +13,15 @@ import { NodeRelatedProvider } from '~/utils/providers/NodeRelatedProvider';
|
|||
import { useLoadNode } from '~/hooks/node/useLoadNode';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { useNodePageParams } from '~/hooks/node/useNodePageParams';
|
||||
import { GetServerSidePropsContext } from 'next';
|
||||
import { InferGetServerSidePropsType } from 'next';
|
||||
import { apiGetNode } from '~/api/node';
|
||||
import { ApiGetNodeResponse } from '~/types/node';
|
||||
|
||||
export async function getServerSideProps(
|
||||
context: GetServerSidePropsContext<{ id: string }, ApiGetNodeResponse>
|
||||
) {
|
||||
const id = parseInt(context.query.id as string, 10);
|
||||
export const getServerSideProps = async context => {
|
||||
if (!context.params?.id) {
|
||||
return { props: {} };
|
||||
}
|
||||
|
||||
const id = parseInt(context.params.id, 10);
|
||||
|
||||
if (!id) {
|
||||
return { props: {} };
|
||||
|
@ -36,12 +37,11 @@ export async function getServerSideProps(
|
|||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
type Props = RouteComponentProps<{ id: string }> & {
|
||||
fallbackData?: ApiGetNodeResponse;
|
||||
};
|
||||
|
||||
type Props = RouteComponentProps<{ id: string }> &
|
||||
InferGetServerSidePropsType<typeof getServerSideProps>;
|
||||
|
||||
const NodePage: FC<Props> = observer(props => {
|
||||
const id = useNodePageParams();
|
||||
const { node, isLoading, update, lastSeen } = useLoadNode(parseInt(id, 10), props.fallbackData);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue