Type safety in actionResult in shouldRevalidate? #9417
Unanswered
nikolailehbrink
asked this question in
Q&A
Replies: 1 comment
-
I did something like this to infer the type export const shouldRevalidate = ({
defaultShouldRevalidate,
actionResult,
}: Omit<ShouldRevalidateFunctionArgs, "actionResult"> & {
actionResult: Awaited<ReturnType<Awaited<ReturnType<typeof action>>["json"]>>;
}) => {
if (actionResult.data) {
return true;
}
return defaultShouldRevalidate;
}; but there should be a better way to do it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wondered how I can get type safety for the actionResult parameter of the shouldRevalidate function. For example when using
useActionData
I can get the correct types by writing the following:Now how would I do that inside the shouldRevalidate function?
Beta Was this translation helpful? Give feedback.
All reactions