MCPcopy
hub / github.com/NervJS/nerv / getContextByContextType

Function getContextByContextType

packages/nerv/src/lifecycle.ts:82–92  ·  view source on GitHub ↗
(vnode: FullComponent, parentContext: ParentContext)

Source from the content-addressed store, hash-verified

80}
81
82export function getContextByContextType (vnode: FullComponent, parentContext: ParentContext) {
83 const contextType = vnode.type.contextType
84 const hasContextType = !isUndefined(contextType)
85 const provider = hasContextType ? (parentContext[contextType._id]) : null
86 const context = hasContextType
87 ? (
88 !isNullOrUndef(provider) ? provider.value : contextType._defaultValue
89 )
90 : parentContext
91 return context
92}
93
94export function mountComponent (
95 vnode: FullComponent,

Callers 2

updateMethod · 0.90
mountComponentFunction · 0.85

Calls 2

isUndefinedFunction · 0.90
isNullOrUndefFunction · 0.90

Tested by

no test coverage detected