MCPcopy Create free account
hub / github.com/RobPruzan/react-scratch / mapExternalMetadataToInternalMetadata

Function mapExternalMetadataToInternalMetadata

src/react/core.ts:409–435  ·  view source on GitHub ↗
({
  externalMetadata,
}: {
  externalMetadata: ReactComponentExternalMetadata<AnyProps>;
})

Source from the content-addressed store, hash-verified

407 : { kind: "function", function: component, name: component.name };
408
409const mapExternalMetadataToInternalMetadata = ({
410 externalMetadata,
411}: {
412 externalMetadata: ReactComponentExternalMetadata<AnyProps>;
413}): ReactComponentInternalMetadata => ({
414 provider: null,
415 kind: "real-element",
416 component: mapComponentToTaggedUnion(externalMetadata.component),
417 children: externalMetadata.children.map(
418 (child): ReactComponentInternalMetadata => {
419 const slotNode: ReactComponentInternalMetadata = {
420 kind: "empty-slot",
421 };
422 if (!child) {
423 return slotNode;
424 }
425
426 if (child.kind === "empty-slot") {
427 return slotNode;
428 }
429
430 return child;
431 }
432 ),
433 props: externalMetadata.props,
434 id: crypto.randomUUID(),
435});
436
437const toChild = (
438 child:

Callers 1

createElementFunction · 0.85

Calls 1

Tested by

no test coverage detected