( renderFunction: Props => React$Node, props: Props, currentDispatcher: ?CurrentDispatcherRef, )
| 1195 | } |
| 1196 | |
| 1197 | export function inspectHooks<Props>( |
| 1198 | renderFunction: Props => React$Node, |
| 1199 | props: Props, |
| 1200 | currentDispatcher: ?CurrentDispatcherRef, |
| 1201 | ): HooksTree { |
| 1202 | // DevTools will pass the current renderer's injected dispatcher. |
| 1203 | // Other apps might compile debug hooks as part of their app though. |
| 1204 | if (currentDispatcher == null) { |
| 1205 | currentDispatcher = ReactSharedInternals; |
| 1206 | } |
| 1207 | |
| 1208 | const previousDispatcher = currentDispatcher.H; |
| 1209 | currentDispatcher.H = DispatcherProxy; |
| 1210 | |
| 1211 | let readHookLog; |
| 1212 | let ancestorStackError; |
| 1213 | |
| 1214 | try { |
| 1215 | ancestorStackError = new Error(); |
| 1216 | renderFunction(props); |
| 1217 | } catch (error) { |
| 1218 | handleRenderFunctionError(error); |
| 1219 | } finally { |
| 1220 | readHookLog = hookLog; |
| 1221 | hookLog = []; |
| 1222 | // $FlowFixMe[incompatible-use] found when upgrading Flow |
| 1223 | currentDispatcher.H = previousDispatcher; |
| 1224 | } |
| 1225 | const rootStack = |
| 1226 | ancestorStackError === undefined |
| 1227 | ? ([]: ParsedStackFrame[]) |
| 1228 | : ErrorStackParser.parse(ancestorStackError); |
| 1229 | return buildTree(rootStack, readHookLog); |
| 1230 | } |
| 1231 | |
| 1232 | function setupContexts(contextMap: Map<ReactContext<any>, any>, fiber: Fiber) { |
| 1233 | let current: null | Fiber = fiber; |
no test coverage detected