The prop on the child component is isFavorite not IsFavorite:
<h2>{{ name }} {{ isFavorite ? 'Favorite':''}}</h2>
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
in my Vue 3 app I made myself two components:
App.Vue (father)
<template>
<section>
<header>
<h1>My Friends</h1>
</header>
<ul>
<friend-contact
v-for="friend in friends"
:key="friend.id"
:id="friend.id"
:name="friend.name"
:phone-number="friend.phone"
:email-addresses="friend.email"
:is-favorite="friend.isFavorite"
@toggle-favorite="toggleFavoriteStatus"
>
</friend-contact>
</ul>
</section>
</template>
<script>
export default {
data() {
return {
friends: [
{
id: "manuel",
name: "Manuel Lorenz",
phone: "0123 45678 90",
email: "[email protected]",
isFavorite: true,
},
{
id: "julie",
name: "Julie Jones",
phone: "0987 654421 21",
email: "[email protected]",
isFavorite: false,
},
],
};
},
methods: {
toggleFavoriteStatus(friendId) {
const objFriend = this.friends.find((friend) => friend.id === friendId);
objFriend.isFavorite = !objFriend.isFavorite;
},
},
};
</script>
FriendContact.vue (child)
<template>
<li>
<h2>{{ name }} {{ IsFavorite ? 'Favorite':''}}</h2>
<button @click="toggleFavorite">
Toggle Favorite
</button>
<button @click="toggleDetails">
{{ detailsAreVisible ? "Hide" : "Show" }} Details
</button>
<ul v-if="detailsAreVisible">
<li>
<strong>Phone:</strong>
{{ phoneNumber }}
</li>
<li>
<strong>Email:</strong>
{{ emailAddress }}
</li>
</ul>
</li>
</template>
<script>
export default {
props: {
id: {
type: String,
required: true,
},
name: {
type: String,
required: true,
},
phoneNumber: String,
emailAddress: String,
isFavorite: {
type: Boolean,
required: false,
validator: function (value) {
return value === true || value === false;
},
},
},
data() {
return {
detailsAreVisible: false,
};
},
methods: {
toggleDetails() {
this.detailsAreVisible = !this.detailsAreVisible;
},
toggleFavorite(){
this.$emit('toggle-favorite',this.id);
}
},
};
</script>
When loading the page I get the following error:
[Vue warn]: Property "IsFavorite" was accessed during render but is not defined on instance.
at <FriendContact key="manuel" id="manuel" name="Manuel Lorenz" ... >
at <App>
I do not understand why ... it compiles me but does not render me then strig after name and gives me that error
The prop on the child component is isFavorite not IsFavorite:
<h2>{{ name }} {{ isFavorite ? 'Favorite':''}}</h2>
Please or to participate in this conversation.