Skip to content
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@benbender
Comment options

Answer selected by benbender
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants