findChildrenWithProvide

Commons
stable

Walks a Vue VNode tree and returns all ComponentInternalInstance nodes that have a specific injection key in their provides object. Used by layout components to locate child components registered via provide/inject.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

key
required
InjectionKey<any> | symbol
The injection key to search for. Components that called provide(key, …) will be collected.
vnode
VNodeChild
The VNode subtree to walk. Typically the subTree of the parent component instance. Undefined returns an empty array.

API

Return value

The value returned by this util.

A flat array of all component instances that provide the given key, found anywhere in the VNode subtree.

Usage

Examples

Ready-to-paste usage snippets.

Locate children by injection key

typescript