Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix: register callback before calling setup
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jul 27, 2022
1 parent 9975293 commit d3fbb3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/nuxt/src/app/components/client-only.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ export function createClientOnly (component) {
return defineComponent({
...component,
setup (props, ctx) {
const res = setup?.(props, ctx) || {}

const mounted$ = ref(false)
onMounted(() => { mounted$.value = true })

return Promise.resolve(res)
.then(() => ({ ...res, mounted$ }))
return Promise.resolve(setup?.(props, ctx) || {})
.then(res => ({ ...res, mounted$ }))
},
render (ctx, cache, props, state, data, options) {
return ctx.mounted$
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/basic/components/ClientWrapped.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ function exposedFunc () {
}
defineExpose({ exposedFunc })
await new Promise(resolve => setTimeout(resolve, 300))
onMounted(() => { console.log('mounted') })
</script>

<template>
Expand Down

0 comments on commit d3fbb3c

Please sign in to comment.