routeData arguments
How do I pass arguments from component props into a routeData function (for data-fetching with a key for example) ?
1 Reply
code in question:
type GoalCardProps = {
goalId: string,
description: string,
deadline: string
}
export function routeData() {
return createRouteData(async (goalId) => {
const response = await pb.collection('milestones').getFullList({
filter:
parent = "${*goalId*}"
})
console.log(response)
let milestones: Goal[] = []
return "milestones"
})
}
export default function GoalCard(props: GoalCardProps) {
const milestones = useRouteData<typeof routeData>()
return (
<div class="text-center text-3xl">
<span><strong>{props.description}</strong></span>
<span> | {props.deadline} </span>
<input type="checkbox" class="checkbox" />
<button class="btn btn-square">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg>
</button>
</div>
)
}