I'm curious about passing props into setup and what are best practices to update variables/templates based on property changes.
I'm curious about reactive and computed.
For example:
setup(props) {
// Setup global config settings
const config = computed(() => {
return {
// See if the component is disabled
isDisabled: props.disabled, // (1)
// Test for rounded
isRounded: props.rounded // (2)
}
})
return { config }
}
- Should
config.isDisabledandconfig.isRoundedbe wrapped in their owncomputedfunction as they are both different and independent? However, it is easy to just stick them into one big function. What is best practice in this regard? - Does the entire
configfunction evaluate once a single property changes within the function or can it recognize the change and update what is required? - Per docs,
reactiveis deeply reactive and used for objects, however, I've noticed it doesn't update to property changes. Therefore, I've been treating it more likedatain Vue 2. Am I missing something or is this correct treatment?