Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 2x 248x 709x 44x 44x 665x 204x 204x 248x 2x | import { IComponent } from '@zeedhi/common';
/**
* Search for a component inside an array of children
*
* The children array can be either an array of IComponent or an array of Component
*/
const getChild = <T extends IComponent>(children: any[], name: string): T => {
let found: any;
children.forEach((child) => {
if (child.name === name) {
found = child;
return;
}
if (child.children && child.children.length > 0) {
const result = getChild<T>(child.children, name) as T;
if (result) found = result;
}
});
return found;
};
export { getChild };
|