Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
props attributes aren't updated

on a component I'm receiving blog object through props

props: {
  blog: {
    type: Object,
    default: null,
  },
}

here I declare comments in data

  data: () => ({
    comments: [],
    // rest needed variables
  }),

and on the created method of that component I'm doing this:

    
created() {
  if (this.blog && this.blog.comments) {
    this.comments = [];
    this.$nextTick().then(() => {
      this.comments = this.$srv.myMethod(this.blog.comments);
      console.log('this.comments);
      this.$root.$emit('comments', this.blog, this.comments);
    });
  } else {
    // rest of code
  }
},

the problem here is that this.blog.comments isn't updated.

I expect to get changes whenever a change occur. any insights please ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are using created hook that is only executed 1 time when you create the component.

To check your prop changes you can use a watcher:

  watch: {
    blog: {
      handler(newValue) {
        // Your stuff here newValue contains the blog object updated
      },
      deep: true
    }
  }

But if you only need blog.comments maybe is better to use your prop like blogComments as array and watch only this prop instead the full object.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!