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
๐ The bug
I think the beforeNuxtRender is not getting called at the right place when it is placed in the setup function.
๐ ๏ธ To reproduce
I'm using this code:
<template>
<div>
hello
</div>
</template>
<scriptlang="ts">import { defineComponent, useContext } from'@nuxtjs/composition-api'exportdefaultdefineComponent({ layout: 'empty', //this is just a totally empty layout with <div><Nuxt /></div> in it setup () {const { ssrContext, beforeNuxtRender } =useContext()if (process.server) {//printing the functions before injectionconsole.log('in setup before declaring function', ssrContext.beforeRenderFns)//passing the function the normal waybeforeNuxtRender(() => {console.log('beforeRenderFn1') })//injecting the function directly in the beforeRenderFnsssrContext.beforeRenderFns.push(() => {console.log('beforeRenderFn2') })//printing the functions after injectionconsole.log('in setup after declaring function', ssrContext.beforeRenderFns) } }})</script>
And in the generated server.js I've place two console.log statment like this:
After this, the printed server output is the following:
before beforeRender [] 08:58:47
after beforeRender [] 08:58:47
in setup before declaring function[] 08:58:47
in setup after declaring function[ 08:58:47
[Function (anonymous)],
[Function (anonymous)]
]
The frontend not printing 'beforeRenderFn1' or 'beforeRenderFn2' either.
๐ Expected behaviour
The function which had been passed into beforeNuxtRender should be called when the server.js calls the beforeRender and all the beforeRenderFns. The console output should be reversed: the in setup part should come first and the beforeRender part after. According to this closed issue it has been also suggested that is should work when placed in the setup function.
The text was updated successfully, but these errors were encountered:
๐ The bug
I think the beforeNuxtRender is not getting called at the right place when it is placed in the setup function.
๐ ๏ธ To reproduce
I'm using this code:
And in the generated server.js I've place two console.log statment like this:
After this, the printed server output is the following:
The frontend not printing 'beforeRenderFn1' or 'beforeRenderFn2' either.
๐ Expected behaviour
The function which had been passed into beforeNuxtRender should be called when the server.js calls the beforeRender and all the beforeRenderFns. The console output should be reversed: the in setup part should come first and the beforeRender part after. According to this closed issue it has been also suggested that is should work when placed in the setup function.
The text was updated successfully, but these errors were encountered: