alexcodes
alexcodes

Reputation: 415

Why does my functions gets recognized as an Object when using an arrow function inside it?

I'm using a find() with an arrow function in an method which I'm passing to a child component as a prop. The method works just one time. I'm getting an Invalid Prop warning. The second time the method is not executed anymore.

vue.esm.js:628 [Vue warn]: Invalid prop: type check failed for prop "selectFkt". Expected Function, got Object 

found in

---> <CompareView> at src/components/customComponents/compareView.vue
       <ElementConfigurator> at src/components/customInputs/ownAwesomeInputs/elementConfigurator.vue
         <Baustoffassistent> at src/components/SmartBrick/Baustoffassistent.vue
           <VApp>
             <App> at src/App.vue
               <Root>
selectArticle(article) {
      this.selectArticle = article;
      var elementID = this.selectedelement.id;
      this.selectArticle.elementID = elementID;

      var element = this.elements.find(el => el.id === elementID);
      element.artSelected = true;
}

Does someone have any solution for this problem? Would be glad with any help.

Upvotes: 1

Views: 124

Answers (1)

Thiago Barcala
Thiago Barcala

Reputation: 7343

The problem is the line

this.selectArticle = article;

You are replacing the component method with an object. Maybe you wanted to assign article to this.selectedArticle?

Upvotes: 1

Related Questions