MCPcopy
hub / github.com/facebook/react / renderElement

Function renderElement

packages/react-server/src/ReactFizzServer.js:2898–3019  ·  view source on GitHub ↗
(
  request: Request,
  task: Task,
  keyPath: KeyNode,
  type: any,
  props: Object,
  ref: any,
)

Source from the content-addressed store, hash-verified

2896}
2897
2898function renderElement(
2899 request: Request,
2900 task: Task,
2901 keyPath: KeyNode,
2902 type: any,
2903 props: Object,
2904 ref: any,
2905): void {
2906 if (typeof type === 'function') {
2907 if (shouldConstruct(type)) {
2908 renderClassComponent(request, task, keyPath, type, props);
2909 return;
2910 } else {
2911 renderFunctionComponent(request, task, keyPath, type, props);
2912 return;
2913 }
2914 }
2915 if (typeof type === 'string') {
2916 renderHostElement(request, task, keyPath, type, props);
2917 return;
2918 }
2919
2920 switch (type) {
2921 // LegacyHidden acts the same as a fragment. This only works because we
2922 // currently assume that every instance of LegacyHidden is accompanied by a
2923 // host component wrapper. In the hidden mode, the host component is given a
2924 // `hidden` attribute, which ensures that the initial HTML is not visible.
2925 // To support the use of LegacyHidden as a true fragment, without an extra
2926 // DOM node, we would have to hide the initial HTML in some other way.
2927 // TODO: Delete in LegacyHidden. It's an unstable API only used in the
2928 // www build. As a migration step, we could add a special prop to Offscreen
2929 // that simulates the old behavior (no hiding, no change to effects).
2930 case REACT_LEGACY_HIDDEN_TYPE:
2931 case REACT_STRICT_MODE_TYPE:
2932 case REACT_PROFILER_TYPE:
2933 case REACT_FRAGMENT_TYPE: {
2934 const prevKeyPath = task.keyPath;
2935 task.keyPath = keyPath;
2936 renderNodeDestructive(request, task, props.children, -1);
2937 task.keyPath = prevKeyPath;
2938 return;
2939 }
2940 case REACT_ACTIVITY_TYPE: {
2941 renderActivity(request, task, keyPath, props);
2942 return;
2943 }
2944 case REACT_SUSPENSE_LIST_TYPE: {
2945 renderSuspenseList(request, task, keyPath, props);
2946 return;
2947 }
2948 case REACT_VIEW_TRANSITION_TYPE: {
2949 if (enableViewTransition) {
2950 renderViewTransition(request, task, keyPath, props);
2951 return;
2952 }
2953 // Fallthrough
2954 }
2955 case REACT_SCOPE_TYPE: {

Callers 4

renderMemoFunction · 0.70
renderLazyComponentFunction · 0.70
replayElementFunction · 0.70
retryNodeFunction · 0.70

Calls 15

renderClassComponentFunction · 0.85
renderHostElementFunction · 0.85
renderNodeDestructiveFunction · 0.85
renderActivityFunction · 0.85
renderSuspenseListFunction · 0.85
renderViewTransitionFunction · 0.85
renderSuspenseBoundaryFunction · 0.85
renderForwardRefFunction · 0.85
renderMemoFunction · 0.85
renderContextProviderFunction · 0.85
renderContextConsumerFunction · 0.85
renderLazyComponentFunction · 0.85

Tested by

no test coverage detected