ElementCollection.selectByComponentData()
Home > @backstage/core-plugin-api
> ElementCollection
> selectByComponentData
Narrows the set of selected components by doing a deep traversal and only including those that have defined component data for the given key
.
Signature:
selectByComponentData(query: {
key: string;
withStrictError?: string;
}): ElementCollection;
Parameters
Parameter |
Type |
Description |
---|---|---|
query |
{ key: string; withStrictError?: string; } |
Filtering query. |
Remarks
Whether an element in the tree has component data set for the given key is determined by whether getComponentData
returns undefined.
The traversal does not continue deeper past elements that match the criteria, and it also includes the root children in the selection, meaning that if the, of all the currently selected elements contain data for the given key, this method is a no-op.
If withStrictError
is set, the resulting selection must be a full match, meaning there may be no elements that were excluded in the selection. If the selection is not a clean match, an error will be throw with withStrictError
as the message.