How to handle watching of a reactive/non-reactive value as short as possible?

67 views Asked by At

I have a list dropdown component that accepts items props which could be a reactive or non-reactive object/array. So I watch it to react when the items change. But when I provide a static non-reactive array/object it issues warning that non-reactive value is provided for watch(). Yes, I don't care watching a non-reactive value.

1

There are 1 answers

2
Boussadjra Brahim On BEST ANSWER

Try to use the toValue utility as getter for your watcher (requires vue +3.3):

watch(()=>toValue(items),(newItems)=>{
// your process
})