MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / findChildProps

Function findChildProps

src/components/common/TabsLayout.jsx:35–48  ·  view source on GitHub ↗

* Recursively searches React children for a component of the given type * and returns its props. Returns null if not found.

(children, targetType)

Source from the content-addressed store, hash-verified

33 * and returns its props. Returns null if not found.
34 */
35function findChildProps(children, targetType) {
36 let result = null;
37 React.Children.forEach(children, child => {
38 if (result || !child || !child.props) return;
39 if (child.type === targetType) {
40 result = child.props;
41 return;
42 }
43 if (child.props.children) {
44 result = findChildProps(child.props.children, targetType);
45 }
46 });
47 return result;
48}
49
50function getActiveCode(codeObject, lang, style) {
51 if (!codeObject) return { source: '', label: '', css: '' };

Callers 1

TabsLayoutFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected