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

Function render

packages/react-native-renderer/src/ReactFabric.js:108–172  ·  view source on GitHub ↗
(
  element: Element<ElementType>,
  containerTag: number,
  callback: ?() => void,
  concurrentRoot: ?boolean,
  options: ?RenderRootOptions,
)

Source from the content-addressed store, hash-verified

106}
107
108function render(
109 element: Element<ElementType>,
110 containerTag: number,
111 callback: ?() => void,
112 concurrentRoot: ?boolean,
113 options: ?RenderRootOptions,
114): ?ElementRef<ElementType> {
115 if (disableLegacyMode && !concurrentRoot) {
116 throw new Error('render: Unsupported Legacy Mode API.');
117 }
118
119 let root = roots.get(containerTag);
120
121 if (!root) {
122 // TODO: these defaults are for backwards compatibility.
123 // Once RN implements these options internally,
124 // we can remove the defaults and ReactFiberErrorDialog.
125 let onUncaughtError = nativeOnUncaughtError;
126 let onCaughtError = nativeOnCaughtError;
127 let onRecoverableError = defaultOnRecoverableError;
128
129 if (options && options.onUncaughtError !== undefined) {
130 onUncaughtError = options.onUncaughtError;
131 }
132 if (options && options.onCaughtError !== undefined) {
133 onCaughtError = options.onCaughtError;
134 }
135 if (options && options.onRecoverableError !== undefined) {
136 onRecoverableError = options.onRecoverableError;
137 }
138 let onDefaultTransitionIndicator = nativeOnDefaultTransitionIndicator;
139 if (enableDefaultTransitionIndicator) {
140 if (options && options.onDefaultTransitionIndicator !== undefined) {
141 onDefaultTransitionIndicator = options.onDefaultTransitionIndicator;
142 }
143 }
144
145 const publicRootInstance = createPublicRootInstance(containerTag);
146 const rootInstance = {
147 publicInstance: publicRootInstance,
148 containerTag,
149 };
150
151 // TODO (bvaughn): If we decide to keep the wrapper component,
152 // We could create a wrapper for containerTag as well to reduce special casing.
153 root = createContainer(
154 rootInstance,
155 concurrentRoot ? ConcurrentRoot : LegacyRoot,
156 null,
157 false,
158 null,
159 '',
160 onUncaughtError,
161 onCaughtError,
162 onRecoverableError,
163 onDefaultTransitionIndicator,
164 null,
165 );

Calls 6

createPublicRootInstanceFunction · 0.90
createContainerFunction · 0.90
updateContainerFunction · 0.90
getPublicRootInstanceFunction · 0.90
setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected