Imagine the following situation:
I have a Menu component with 2 props:
itemsfilterTerm
The Menu component can't just simply display the items.. It has to filter it first according to the given filterTerm.
This raises 2 questions:
I don't know where to process
itemsbefore displaying them. I've researched the Components documentation and they don't seem to mention any life-cycle methods.Is it a good idea to mutate the received
itemsprop? Unless Vue performs a deep clone on every render, which I find unreasonable, mutating a prop may have side-effects. Therefore, I shouldn't actually filter the receiveditems. I should clone it first, but then where would I do it? I could do it in thedata:function() { }but then mymethodsare not available there :(
So, what is the proper way of filtering the items before displaying them?