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

Function register

packages/react-refresh/src/ReactFreshRuntime.js:301–344  ·  view source on GitHub ↗
(type: any, id: string)

Source from the content-addressed store, hash-verified

299}
300
301export function register(type: any, id: string): void {
302 if (__DEV__) {
303 if (type === null) {
304 return;
305 }
306 if (typeof type !== 'function' && typeof type !== 'object') {
307 return;
308 }
309
310 // This can happen in an edge case, e.g. if we register
311 // return value of a HOC but it returns a cached component.
312 // Ignore anything but the first registration for each type.
313 if (allFamiliesByType.has(type)) {
314 return;
315 }
316 // Create family or remember to update it.
317 // None of this bookkeeping affects reconciliation
318 // until the first performReactRefresh() call above.
319 let family = allFamiliesByID.get(id);
320 if (family === undefined) {
321 family = {current: type};
322 allFamiliesByID.set(id, family);
323 } else {
324 pendingUpdates.push([family, type]);
325 }
326 allFamiliesByType.set(type, family);
327
328 // Visit inner types because we might not have registered them.
329 if (typeof type === 'object' && type !== null) {
330 switch (getProperty(type, '$$typeof')) {
331 case REACT_FORWARD_REF_TYPE:
332 register(type.render, id + '$render');
333 break;
334 case REACT_MEMO_TYPE:
335 register(type.type, id + '$type');
336 break;
337 }
338 }
339 } else {
340 throw new Error(
341 'Unexpected call to React Refresh in a production environment.',
342 );
343 }
344}
345
346export function setSignature(
347 type: any,

Callers 2

WebpackMock.jsFile · 0.50
region.jsFile · 0.50

Calls 5

setMethod · 0.80
getPropertyFunction · 0.70
hasMethod · 0.65
getMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected