I have seen many questions and answer but they don't solve my problem, I'm just trying to show/hide when I click in the parent components menu button the drawer should open, after the first-time load it works fine but when I close this it shows me this error. I just want to pass true or false in the props
Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "drawer"
This what I'm trying to do.
In the parent
<template>
<div @click="drawer = true" class="hamburger">
<span></span>
<span></span>
<span></span>
</div>
<mobile-drawer-menu :drawer="drawer"/>
</template>
<script>
import MobileDrawerMenu from "./MobileDrawerMenu";
export default {
components : {
MobileDrawerMenu
},
data() {
return {
drawer : false,
}
},
}
</script>
In child
<template>
<div v-if="drawer" class="fixed top-0 left-0 z-200">
<div @click="drawer = false" class="overlay"></div>
<div class="drawer-wrapper">
<div class="drawer-close">
<div class="flex items-center justify-end">
<svg @click="drawer = false"></svg>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "MobileDrawerMenu",
props : {
drawer : {
type : Boolean,
required : true
}
},
}
</script>