Why vapor component getCurrentInstance return null? #15134
Replies: 3 comments 3 replies
|
Yes, this is expected for Vapor right now, not a missing lifecycle instance. Vapor has its own internal instance shape, but it is not the same classic VNode/runtime-core instance that existing For app and library code, the safer migration path is to move off |
|
There is a Vapor instance, but it is deliberately not a On the Vapor branch, Vue keeps a So this is an API boundary, not a missing lifecycle context. Libraries should use public APIs such as |
|
Changing the internal shape shouldn't be equated to erasing the API's foundational capability. Object shape and API availability are two entirely different concepts. Even if Vapor alters the rendering infrastructure, the core identity of a component instance as a "context carrier" remains unchanged. Properties like appContext, parent, and provides are universal concepts shared by both paradigms. Returning null simply because the rendering fields differ feels like leaking internal implementation details to the public boundary. Instead of a hard cut, wouldn't it make more sense to expose a unified, polymorphic interface that safely provides access to these common context fields? Furthermore, if the intention behind returning null is to protect users from relying on a mismatching object shape and getting runtime errors, returning null is actually a worse and more misleading error. Returning null explicitly signals to the ecosystem that "there is no active component context at all," which is factually incorrect—the Vapor component is actively running. If a library attempts to read a legacy field from a Vapor instance, it yields a clear, local error (e.g., Cannot read property of undefined), which immediately signals a shape mismatch. However, returning null completely misleads the library into thinking it's being executed outside of a component lifecycle entirely, causing unnecessary shield crashes and hiding the real core metadata (appContext, parent, provides) that is actually there. Preventing a shape mismatch shouldn't mean faking the absence of the entire context. |
Uh oh!
There was an error while loading. Please reload this page.
This behavior will break so many tools in vue & Why there is a vapor shape instance but still just return null?
All reactions