-
|
Given the following code: export const routeData = ({ params }: RouteDataFuncArgs) => {
console.log(params.projectId);
return createServerData(async (projectId: string) =>
db.project.findUniqueOrThrow({
where: {
id: projectId
}
})
);
};I'm struggeling to provide projectId to the I couldn't find any doc/example on this usecase. Am I completely out of track or am I missing smth obvious? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
It works the same way Resources work in Solid export const routeData = ({ params }: RouteDataFuncArgs) => {
return createServerData(() => params.projectId, async (projectId: string) =>
db.project.findUniqueOrThrow({
where: {
id: projectId
}
})
);
};This might seem weird at first but it lets us make a reactive connection so that if projectId ever changes we can trigger again. This can be done completely fine-grained per resource. We can also use this to make keys for invalidation. This first argument supports React Query-like keys. |
Beta Was this translation helpful? Give feedback.
It works the same way Resources work in Solid
This might seem weird at first but it lets us make a reactive connection so that if projectId ever changes we can trigger again. This can be done completely fine-grained per resource. We can also use this to make keys for invalidation. This first argument supports React Query-like keys.