0

I'm passing data to child component like this:

Parent.vue

<template>
 <vote-buttons :data="data">
 </vote-buttons>
</template>

props: {
 comment: {type: Object}
},
setup(props) {
 const data = {
  'score': props.comment.score,
  'hasVoteOfUser': props.comment.hasVoteOfUser,
 }

 return { data }
}

Child.vue

props: {
 data: { type: Object }
},

// or

props: {
 data: {
  score: { type: Number },
  hasVoteOfUser: { type: Boolean }
}

When i'm accessing {{ data.score }} in child component, i'm getting Uncaught TypeError: $props.data is undefined and just {{ data }} renders whole object { "score": 1, "hasVoteOfUser": true }. Why rendering of one property doesn't work? Thanks

1 Answers1

0

That's my fault, there was another component on the same page, which used the same child and did not provide data prop. This question was useful for me: Uncaught TypeError: $props.currentQuestion is undefined Vue