MCPcopy Index your code
hub / github.com/react/react / setSignature

Function setSignature

packages/react-refresh/src/ReactFreshRuntime.js:346–377  ·  view source on GitHub ↗
(
  type: any,
  key: string,
  forceReset?: boolean = false,
  getCustomHooks?: () => Array<Function>,
)

Source from the content-addressed store, hash-verified

344}
345
346export function setSignature(
347 type: any,
348 key: string,
349 forceReset?: boolean = false,
350 getCustomHooks?: () => Array<Function>,
351): void {
352 if (__DEV__) {
353 if (!allSignaturesByType.has(type)) {
354 allSignaturesByType.set(type, {
355 forceReset,
356 ownKey: key,
357 fullKey: null,
358 getCustomHooks: getCustomHooks || (() => []),
359 });
360 }
361 // Visit inner types because we might not have signed them.
362 if (typeof type === 'object' && type !== null) {
363 switch (getProperty(type, '$$typeof')) {
364 case REACT_FORWARD_REF_TYPE:
365 setSignature(type.render, key, forceReset, getCustomHooks);
366 break;
367 case REACT_MEMO_TYPE:
368 setSignature(type.type, key, forceReset, getCustomHooks);
369 break;
370 }
371 }
372 } else {
373 throw new Error(
374 'Unexpected call to React Refresh in a production environment.',
375 );
376 }
377}
378
379// This is lazily called during first render for a type.
380// It captures Hook list at that time so inline requires don't break comparisons.

Callers 1

Calls 3

setMethod · 0.80
getPropertyFunction · 0.70
hasMethod · 0.65

Tested by

no test coverage detected