-
Notifications
You must be signed in to change notification settings - Fork 100
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
fix: useMeta() throws error if used in a layout #64
Labels
bug
Something isn't working
Comments
miii
added a commit
to miii/composition-api
that referenced
this issue
May 18, 2020
Set and update head metadata anytime in your setup method ✅ Closes: nuxt-community#64
miii
added a commit
to miii/composition-api
that referenced
this issue
May 18, 2020
Set or update head metadata anytime in your setup method ✅ Closes: nuxt-community#64
miii
added a commit
to miii/composition-api
that referenced
this issue
May 18, 2020
Set or update head metadata anytime in your setup method ✅ Closes: nuxt-community#64
Error is not closed at all, can still reproduce with last version : layouts/default.vue export default defineComponent({
name: 'ContentLayout',
setup(props, ctx) {
const { title } = useMeta()
title.value = 'Test'
return {title}
}
//... Getting the error : |
@Mikaleb Would you mind providing a reproduction? |
@danielroe I tried and saw that my version was not updated for some reason, my apologies ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🐛 The bug
The
head: {}
property triggers an error inside@vue/composition-api
if used in a layout component, thususeMeta()
cannot be used.Pages seems to work as expected. The problem is caused by
reactive()
not being used in the correct scope (too soon in the Nuxt lifecycle?).composition-api/src/meta.ts
Lines 43 to 53 in 48547f0
I've resolved the issue myself in a fork by using
Vue.observable()
instead ofreactive()
.I'll submit a PR when it's ready to be reviewed.
🛠️ To reproduce
Steps to reproduce the behavior:
head: {}
to your layoutUse this sandbox to reproduce the error.
https://codesandbox.io/s/nuxt-composition-api-usemeta-layout-issue-r14yy?file=/layouts/default.vue
🌈 Expected behaviour
useMeta()
should work in layout components as expected.The text was updated successfully, but these errors were encountered: