is it better to keep all the props in one large mixin?

If your component library is not constrained to using Vue 2 you might want to take a look at Vue Composition API to share functionality (methods + reactive state) between different components.

Mixins might not be what you really want to be using because you kind of lose information as to what features/props/methods really will be put inside your component without re-checking the mixin code. You also might run into issues when component options get merged by Vue at runtime. Check out these posts for more information: https://css-tricks.com/how-the-vue-composition-api-replaces-vue-mixins/ https://reactjs.org/blog/2016/07/13/mixins-considered-harmful.html

As for sharing props: What I’ve seen just yesterday (but not yet tried!) in a talk by John Leider – creator of Vuetify – is create a function that returns the props you want to reuse between components. Then you just call said function inside your props definition and use the spread operator.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top