beforeRouteEnter
does not have an injection context if component is not yet loaded
#2051
Labels
beforeRouteEnter
does not have an injection context if component is not yet loaded
#2051
Reproduction
https://jsfiddle.net/rv3p5ajn/13/
Code, if JSFiddle is down
Steps to reproduce the bug
Expected behavior
After all clicks value of
hasInjectionContext()
should betrue
.Actual behavior
On first and second clicks
hasInjectionContext()
isfalse
. On third and fourth, when promises are already resolved,hasInjectionContext()
istrue
.Additional information
According to the docs, all guards should have an injection context.
All other guards do have an injection context, but only before the first yield.
I think the problem lies somewhere within
runWithContext
, because it behaves weirdly with promises:Output is
true
, thenfalse
-- context is reset after first yield.Maybe the bug is in
vuejs/core
?EDIT: Turns out that the weird behaviour of
runWithContext
with async functions is known and kind of documented in Nuxt's docs: https://nuxt.com/docs/api/composables/use-nuxt-app#runwithcontextThe text was updated successfully, but these errors were encountered: