MCPcopy Create free account
hub / github.com/microsoft/SandDance / lazy

Function lazy

docs/external/js/react.development.js:1452–1500  ·  view source on GitHub ↗
(ctor)

Source from the content-addressed store, hash-verified

1450 }
1451
1452 function lazy(ctor) {
1453 var lazyType = {
1454 $$typeof: REACT_LAZY_TYPE,
1455 _ctor: ctor,
1456 // React uses these fields to store the result.
1457 _status: -1,
1458 _result: null
1459 };
1460
1461 {
1462 // In production, this would just set it on the object.
1463 var defaultProps;
1464 var propTypes;
1465 Object.defineProperties(lazyType, {
1466 defaultProps: {
1467 configurable: true,
1468 get: function () {
1469 return defaultProps;
1470 },
1471 set: function (newDefaultProps) {
1472 error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
1473
1474 defaultProps = newDefaultProps; // Match production behavior more closely:
1475
1476 Object.defineProperty(lazyType, 'defaultProps', {
1477 enumerable: true
1478 });
1479 }
1480 },
1481 propTypes: {
1482 configurable: true,
1483 get: function () {
1484 return propTypes;
1485 },
1486 set: function (newPropTypes) {
1487 error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
1488
1489 propTypes = newPropTypes; // Match production behavior more closely:
1490
1491 Object.defineProperty(lazyType, 'propTypes', {
1492 enumerable: true
1493 });
1494 }
1495 }
1496 });
1497 }
1498
1499 return lazyType;
1500 }
1501
1502 function forwardRef(render) {
1503 {

Callers

nothing calls this directly

Calls 1

errorFunction · 0.70

Tested by

no test coverage detected