MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / declares

Function declares

src/artifacts/preview.ts:114–119  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

112 // declare the hooks the model didn't already bring into scope itself.
113 const ALL_HOOKS = ['useState', 'useEffect', 'useRef', 'useMemo', 'useCallback', 'useReducer', 'useContext', 'useLayoutEffect'];
114 const declares = (name: string): boolean => {
115 // `const { … useState … } = React` OR `const useState = …` OR `function useState`
116 const inDestructure = new RegExp(`(?:const|let|var)\\s*\\{[^}]*\\b${name}\\b[^}]*\\}\\s*=`).test(code);
117 const asBinding = new RegExp(`(?:const|let|var|function)\\s+${name}\\b`).test(code);
118 return inDestructure || asBinding;
119 };
120 const hooksToInject = ALL_HOOKS.filter(h => !declares(h));
121 const hookLine = hooksToInject.length
122 ? `const { ${hooksToInject.join(', ')} } = React;\n`

Callers 1

reactHarnessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected