-
Hello everyone 👋 Is there built-in way to in infer serialized return type of loader for MetaFunion’s data prop in param? I know that there were many discussions & improvements related to loader type inference. Auto inference for Also the types to make inference work for |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Yeah, there is no However, you can use the utility type import { type UseDataFunctionReturn } from "@remix-run/react/dist/components";
export const meta = ({
data,
}: {
data: UseDataFunctionReturn<typeof loader>;
}) => {
return {
title: data.greeting,
};
}; As for why it's in the |
Beta Was this translation helpful? Give feedback.
Yeah, there is no
MetaArgs
type likeLoaderArgs
, etc.However, you can use the utility type
UseDataFunctionReturn
to get the correct type. It's not exported by default, so you'll need a deep import.As for why it's in the
react
package, it's most likely because it was needed primarily for theuseLoaderData
hook, which is implemented there. Accessing the serialized data is done at the component level.