XoutDragon
XoutDragon
CCConvex Community
Created by XoutDragon on 5/9/2024 in #support-community
Metadata + Convex
Tyvm
7 replies
CCConvex Community
Created by XoutDragon on 5/9/2024 in #support-community
Metadata + Convex
Thanks for any help!
7 replies
CCConvex Community
Created by XoutDragon on 5/9/2024 in #support-community
Metadata + Convex
Is there a way to get data from convex without having to use a hook that can be used in outside non react functions? (without having to use an external backend)
7 replies
CCConvex Community
Created by XoutDragon on 5/9/2024 in #support-community
Metadata + Convex
I ran into a problem of useQuery hook not being able to be used in a non react function like
export async function generateMetadata({ params }: DocumentIdPageProps) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const document = useQuery(api.documents.getById, {
documentId: params.documentId,
});

if (document === undefined) {
return {
title: 'Loading...',
description: 'Loading...',
};
}

if (document === null) {
return {
title: 'Not found',
description: 'Not found',
};
}

return {
title: document.title,
};
}
export async function generateMetadata({ params }: DocumentIdPageProps) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const document = useQuery(api.documents.getById, {
documentId: params.documentId,
});

if (document === undefined) {
return {
title: 'Loading...',
description: 'Loading...',
};
}

if (document === null) {
return {
title: 'Not found',
description: 'Not found',
};
}

return {
title: document.title,
};
}
7 replies