T
TanStack2mo ago
variable-lime

notFound data always nested in data.data, and props.data type is unknown

Hello) In defaultNotFoundComponent, props.data is typed as unknown. At runtime, props.data is an object: { data: T, isNotFound: true, routeId: string }. The user-provided data T from return notFound({ data: T }) is unexpectedly nested under props.data.data repo: https://stackblitz.com/edit/tanstack-router-zzqpfdfg?file=src%2Fmain.tsx // need select post by id
//posts.$postId.tsx
loader: ({ context: { queryClient }, params: { postId } }) => {
return notFound({
data: 'Hello data',
});
//posts.$postId.tsx
loader: ({ context: { queryClient }, params: { postId } }) => {
return notFound({
data: 'Hello data',
});
// main.ts
defaultNotFoundComponent={(props) => {
return (
<div>
Error:
{JSON.stringify(props.data, null, 2)}
</div>
);
}}
// main.ts
defaultNotFoundComponent={(props) => {
return (
<div>
Error:
{JSON.stringify(props.data, null, 2)}
</div>
);
}}
4 Replies
passive-yellow
passive-yellow2mo ago
Hello, Would you be able to create an issue in the repository for this? I’ll look into the root cause and help resolve it 🙂
passive-yellow
passive-yellow2mo ago
Thanks! I’ll try to handle it as quickly as possible and open a PR soon!

Did you find this page helpful?