Skip to main content
Retrieves the whole context map that belongs to the closest parent component. Must be called during component initialisation. Useful, for example, if you programmatically create a component and want to pass the existing context to it.

Signature

Returns

contextMap
Map<any, any>
Returns a Map containing all context key-value pairs from the parent component.

Example

Programmatic Component Creation

Parent Component Setting Multiple Contexts

Dynamic Component Using Contexts

Portal/Teleport Pattern

Context Cloning Pattern

Notes

  • Must be called during component initialisation (not in callbacks or effects)
  • Returns a Map object containing all context entries from parent components
  • Primarily useful for programmatic component creation with mount()
  • The returned map includes all contexts from the component tree above the current component
  • Modifying the returned map does not affect the parent’s context