Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Avoid mutating a prop directly #637

Closed
fizerkhan opened this issue Sep 9, 2018 · 8 comments
Closed

Error: Avoid mutating a prop directly #637

fizerkhan opened this issue Sep 9, 2018 · 8 comments

Comments

@fizerkhan
Copy link

fizerkhan commented Sep 9, 2018

I tried to use basic v-select as follows

v-select(v-model="selected", :options="['foo','bar']")

But I am getting following error in the console

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: "filterBy" (found in component <v-select>)

Also v-select does not work. When I typed ba, the option bar is not getting filtered.

How do I fix this issue?

@fizerkhan
Copy link
Author

fizerkhan commented Sep 10, 2018

This happens because [email protected] does not work with [email protected]. So I switched to [email protected]. Then it works fine.

@erikverbeek
Copy link

erikverbeek commented Sep 10, 2018

I'm running into the same error, while 2.4.0 worked fine. Downgrading however removes the new index and 'clearable` features which I think are a great addition.
So I still hope this bug can get fixed.

Edit: I managed to find what caused this bug for me. I was also using vue2-filters, which registers filterBy as a function on every component.

@dmitov
Copy link

dmitov commented Sep 13, 2018

@erikverbeek

I'm running into the same error, while 2.4.0 worked fine. Downgrading however removes the new index and 'clearable` features which I think are a great addition.
So I still hope this bug can get fixed.

Edit: I managed to find what caused this bug for me. I was also using vue2-filters, which registers filterBy as a function on every component.

You found a way to use vue2-filters with this one?

@erikverbeek
Copy link

erikverbeek commented Sep 13, 2018

@dmitov

You found a way to use vue2-filters with this one?

I managed to get it working for my usecase. I was only using the filterBy function from vue2-filters and I was only calling it from inside one of my components methods.

So I got away with just copying the filterBy and contains (which is used by filterBy) functions together with util/index.js into a seperate file and load that instead of the plugin.

This way I have a standalone filterBy function I can call from my scripts.
But this way you lose the ability to use it in your templates.

@akhoury
Copy link

akhoury commented Sep 23, 2018

sounds like a bug, so issue should be reopened

@akhoury
Copy link

akhoury commented Sep 23, 2018

maybe not, looks like it was vue2-filters after all

@t0n1zz
Copy link

t0n1zz commented Sep 29, 2018

so any update from this one? my project using vue2-filters and now i want to integrate select2 (vue-select) into my project too and getting the same errors... any solution?

@akhoury
Copy link

akhoury commented Sep 29, 2018

it's not vue-select's fault, it's vue2-filters's, it's adding a method called filterBy on ALL components, including third party components, as a Global Mixin,

see
https://github.com/freearhey/vue2-filters/blob/c776c271901c075b34295a8ecc1f252a0ababe54/src/index.js#L16-L25

and
https://vuejs.org/v2/guide/mixins.html#Global-Mixin

Use global mixins sparsely and carefully, because it affects every single Vue instance created, including third party components.

I see that @t0n1zz filed an issue there freearhey/vue2-filters#53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants