New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Composition Function Not Working in Production #679
Comments
Please read the docs There are some caveats in Vue's reactivity system where you need to use Also, please use Stackoverflow or Discord to ask questions. Thanks. |
I figured out what the issue was. basically, my component already had a variable @antfu I think that it is a bug with this library. Example: export default {
name: 'job-edit',
setup() {
const data = reactive({
id: 42,
});
return data;
},
data() {
return {
id: null,
}
} it development, the value of |
Thanks, will investigate. |
Any update on this? There are some other functions that I cannot use because of this. It works in development, but not in production. setup(props, context) {
useGoogleMaps('#address', context.emit);
return {};
}, works in development, but not in production. |
it('should work merge with data', async () => {
const opts = {
template: `<div>{{id}}</div>`,
setup() {
const data = reactive({
id: 42,
});
return data;
},
data() {
return {
id: null,
}
},
}
const Constructor = Vue.extend(opts).extend({})
const vm = new Vue(Constructor).$mount()
expect(vm.$el.textContent).toBe("42")
}) |
@rationalthinker1 That doesn't look the same error as the order of assignments being different on I tried to reproduce it in jsfiddle, but getting The merge behaviour seems to be consistent across dev/prod and web/node builds. Please provide a reproduction. |
I found that the demo was modified like codesandbox so that the problem could be reproduced. |
@pikax seems the problem is about HMR: when you first open the page, the value is - <div>{{ id }} - {{ JSON.stringify(id) }}</div>
+ <div>{{ id }} - {{ JSON.stringify(id) }} 11</div> then add more data to data function or setup return block, the value changed to setup() {
const data = reactive({
id: 42,
+ a: 2
});
return data;
},
data() {
return {
id: null,
+ b: 3
};
} |
This code is working in development but not in production. Basically, what this composition function does is set the initial values onto
data
.This is the component that I am using on
Everything else is working. Other components are working. There is no error, and
console.log
ofdata
in the function returns the data that I want for the component.The text was updated successfully, but these errors were encountered: