This is what I'm passing as a prop
<Card tags={ ["HTML", "CSS", "JavaScript", "React"] } />
Here I'm getting the prop
const Card = (props) => {
const { tags } = props; return (
<Cardstyled> <Tags>
{tags.map((tag) => ( <Tag>{tag}</Tag> ))}
</Tags>
</Cardstyled>
)
Everything seems fine but I'm still getting the undefined error
TypeError: Cannot read properties of undefined (reading 'map')
Could anyone help me with this? Thanks!
Its not define at the rendering time, do:
{tags && tags.map((tag) => ( <Tag>{tag}</Tag> ))}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.