Is it better to use watch in onMounted hook or Setup (created hook) in vue compositionApi? Using watch in setup is a bad practice? And if not which one is better at all?
Is it better to use watch in onMounted hook or Setup (created hook) in vue compositionApi? Using watch in setup is a bad practice? And if not which one is better at all?
It always depends on what you want to do.
created() :
mounted()
The created function is generally used for fetching data (maybe) from the API and assign it to data. So if, as in your case, it is only a matter of setup data such as api themes, setup would be preferable.
And if this is not the case and you need / want to use the mounted() function, then you might want to consider whether computed might be the right choice.