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

Function prepareState

fixtures/attribute-behavior/src/App.js:431–522  ·  view source on GitHub ↗
(initGlobals)

Source from the content-addressed store, hash-verified

429}
430
431async function prepareState(initGlobals) {
432 async function getRenderedAttributeValues(attribute, type) {
433 const {
434 ReactStable,
435 ReactDOMStable,
436 ReactDOMServerStable,
437 ReactNext,
438 ReactDOMNext,
439 ReactDOMServerNext,
440 } = initGlobals(attribute, type);
441 const reactStableValue = await getRenderedAttributeValue(
442 ReactStable,
443 ReactDOMStable,
444 ReactDOMServerStable,
445 attribute,
446 type
447 );
448 const reactNextValue = await getRenderedAttributeValue(
449 ReactNext,
450 ReactDOMNext,
451 ReactDOMServerNext,
452 attribute,
453 type
454 );
455
456 let hasSameBehavior;
457 if (reactStableValue.didError && reactNextValue.didError) {
458 hasSameBehavior = true;
459 } else if (!reactStableValue.didError && !reactNextValue.didError) {
460 hasSameBehavior =
461 reactStableValue.didWarn === reactNextValue.didWarn &&
462 reactStableValue.canonicalResult === reactNextValue.canonicalResult &&
463 reactStableValue.ssrHasSameBehavior ===
464 reactNextValue.ssrHasSameBehavior;
465 } else {
466 hasSameBehavior = false;
467 }
468
469 return {
470 reactStable: reactStableValue,
471 reactNext: reactNextValue,
472 hasSameBehavior,
473 };
474 }
475
476 const table = new Map();
477 const rowPatternHashes = new Map();
478
479 // Disable error overlay while testing each attribute
480 uninjectErrorOverlay();
481 for (let attribute of attributes) {
482 const results = new Map();
483 let hasSameBehaviorForAll = true;
484 let rowPatternHash = '';
485 for (let type of types) {
486 const result = await getRenderedAttributeValues(attribute, type);
487 results.set(type.name, result);
488 if (!result.hasSameBehavior) {

Callers 1

componentDidMountFunction · 0.85

Calls 6

setMethod · 0.80
joinMethod · 0.80
addMethod · 0.80
mapMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected