You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using the composition-api, and found a bug of the setup method.
The code below is reactive. When the props of this component has changed, the name will be outputted to the web console.
import{createComponent,watch}from'@vue/composition-api'typeProps={name: string}exportdefaultcreateComponent({props: {name: {type: String}},setup(props: Props){// this is reactivewatch(()=>console.log(props.name))}})
...Although the code below is not reactive.
import{createComponent,watch}from'@vue/composition-api'typeProps={name: string}exportdefaultcreateComponent({props: {name: {type: String}},setup({ name }: Props){// not reactive for propswatch(()=>console.log(name))}})
version of @vue/composition-api
^0.3.2
The text was updated successfully, but these errors were encountered:
You should not destructure props because it's a reactive object. Extracting the properties instead of reading them by accessing the key in the object loose reactivity
Could we have a big warning about this in the docs ? I lost a couple of hours tracking a bug that was caused by destructuring of props.
Or maybe props could be wrapped with toRefs before passing them to the setup function ?
issue
I have been using the composition-api, and found a bug of the
setup
method.The code below is reactive. When the props of this component has changed, the name will be outputted to the web console.
...Although the code below is not reactive.
version of @vue/composition-api
^0.3.2
The text was updated successfully, but these errors were encountered: