#Defining an array received as props

1 messages · Page 1 of 1 (latest)

wicked mulchBOT
#

Hi @alpine dock. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the extracts, it seems like there might be a mismatch between the type of the cards prop and how you're trying to use it in your component.

In your interface Props, you've defined cards as an Array<string>. However, in your component, you're trying to access properties like card.title, card.text, etc., which suggests that each card should be an object, not a string.

Here's how you might define the Props interface based on the usage in your component:

interface CardProps {
    title: string;
    text: string;
    icon: string;
    href: string;
    cta: string;
}

interface Props {
    cards: Array<CardProps>;
}

const {cards} = Astro.props as Props;

This way, each card in the cards array is an object with properties title, text, icon, href, and cta, all of which are strings.

Please note that this answer is based on the information provided in the extracts and the assumption that each card should be an object with the properties you're trying to access. If this assumption is incorrect, you might need to adjust the Props interface accordingly.

For more information on how to use props in Astro components, you can refer to the Astro documentation (https://docs.astro.build/en/core-concepts/astro-components/).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@alpine dock kapa.ai is still learning and improving, please let us know how it did by reacting below