Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Manouher's avatar

Watch props not working (Vuejs 3 & Inertiajs Laravel)

need help, i am trying to listen for data change in props but not working,

export default {
  props: {
    toast: Object,
  },
  data() {
    return {
      visible: false,
    }
  },
  watch: {
    toast: {
      deep: true,
      handler(val, oldVal) {
        console.log(val)
      },
    },
  },
}
0 likes
1 reply
Manouher's avatar
Manouher
OP
Best Answer
Level 1

looking at the inertiajs documentation i was able to solve the problem by modifying the code like this

export default {
  data() {
    return {
      visible: false,
    }
  },
  watch: {
    toast: {
      deep: true,
      handler(val, oldVal) {
        console.log(val)
      },
    },
  },
  computed: {
    toast() {
      return this.$page.props.toast
    },
  },
}

Please or to participate in this conversation.