-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Closed
Labels
β¨ feature requestNew feature or requestNew feature or request
Description
What problem does this feature solve?
import { defineComponent, toRefs, watch } from "vue";
export default defineComponent({
props: {
foo: Boolean
},
setup(props) {
const { foo } = toRefs(props);
// As `foo` might be undefined instead of a Ref
// we cannot watch it directly like this
watch(foo, () => { ... });
}
});
Instead, we need to use:
watch(() => props.foo, () => { ... });
So we need to switch to props.foo
whenever we need to watch it, which doesn't feel very natural to me.
What does the proposed API look like?
For all declared props, always provide { [propName]: undefined }
in the props
parameter of the setup
function so that we can write:
setup(props) { // props being { foo: undefined }
const { foo } = toRefs(props);
// foo is Ref
watch(foo, () => { ... });
}
Matt-Deacalion, posva, Sun79, ljw-codeking and extrem7
Metadata
Metadata
Assignees
Labels
β¨ feature requestNew feature or requestNew feature or request