( element: MixedElement, containerTag: number, callback: ?() => void, options: ?RenderRootOptions, )
| 118 | } |
| 119 | |
| 120 | function render( |
| 121 | element: MixedElement, |
| 122 | containerTag: number, |
| 123 | callback: ?() => void, |
| 124 | options: ?RenderRootOptions, |
| 125 | ): ?ElementRef<ElementType> { |
| 126 | if (disableLegacyMode) { |
| 127 | throw new Error('render: Unsupported Legacy Mode API.'); |
| 128 | } |
| 129 | |
| 130 | let root = roots.get(containerTag); |
| 131 | |
| 132 | if (!root) { |
| 133 | // TODO: these defaults are for backwards compatibility. |
| 134 | // Once RN implements these options internally, |
| 135 | // we can remove the defaults and ReactFiberErrorDialog. |
| 136 | let onUncaughtError = nativeOnUncaughtError; |
| 137 | let onCaughtError = nativeOnCaughtError; |
| 138 | let onRecoverableError = defaultOnRecoverableError; |
| 139 | |
| 140 | if (options && options.onUncaughtError !== undefined) { |
| 141 | onUncaughtError = options.onUncaughtError; |
| 142 | } |
| 143 | if (options && options.onCaughtError !== undefined) { |
| 144 | onCaughtError = options.onCaughtError; |
| 145 | } |
| 146 | if (options && options.onRecoverableError !== undefined) { |
| 147 | onRecoverableError = options.onRecoverableError; |
| 148 | } |
| 149 | |
| 150 | const rootInstance: Container = { |
| 151 | containerTag, |
| 152 | // $FlowExpectedError[incompatible-type] the legacy renderer does not use public root instances |
| 153 | publicInstance: null, |
| 154 | }; |
| 155 | |
| 156 | // TODO (bvaughn): If we decide to keep the wrapper component, |
| 157 | // We could create a wrapper for containerTag as well to reduce special casing. |
| 158 | root = createContainer( |
| 159 | rootInstance, |
| 160 | LegacyRoot, |
| 161 | null, |
| 162 | false, |
| 163 | null, |
| 164 | '', |
| 165 | onUncaughtError, |
| 166 | onCaughtError, |
| 167 | onRecoverableError, |
| 168 | nativeOnDefaultTransitionIndicator, |
| 169 | null, |
| 170 | ); |
| 171 | roots.set(containerTag, root); |
| 172 | } |
| 173 | updateContainer(element, root, null, callback); |
| 174 | |
| 175 | return getPublicRootInstance(root); |
| 176 | } |
| 177 |
nothing calls this directly
no test coverage detected