mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
RN Inspector guard against clicks outside of RN (#9911)
This commit is contained in:
@@ -89,9 +89,19 @@ if (__DEV__) {
|
||||
};
|
||||
|
||||
getInspectorDataForViewTag = function(viewTag: number): Object {
|
||||
const fiber = findCurrentFiberUsingSlowPath(
|
||||
getClosestInstanceFromNode(viewTag),
|
||||
);
|
||||
const closestInstance = getClosestInstanceFromNode(viewTag);
|
||||
|
||||
// Handle case where user clicks outside of ReactNative
|
||||
if (!closestInstance) {
|
||||
return {
|
||||
hierarchy: [],
|
||||
props: emptyObject,
|
||||
selection: null,
|
||||
source: null,
|
||||
};
|
||||
}
|
||||
|
||||
const fiber = findCurrentFiberUsingSlowPath(closestInstance);
|
||||
const fiberHierarchy = getOwnerHierarchy(fiber);
|
||||
const instance = lastNonHostInstance(fiberHierarchy);
|
||||
const hierarchy = createHierarchy(fiberHierarchy);
|
||||
|
||||
@@ -67,6 +67,17 @@ if (__DEV__) {
|
||||
const component = ReactNativeComponentTree.getClosestInstanceFromNode(
|
||||
viewTag,
|
||||
);
|
||||
|
||||
// Handle case where user clicks outside of ReactNative
|
||||
if (!component) {
|
||||
return {
|
||||
hierarchy: [],
|
||||
props: emptyObject,
|
||||
selection: null,
|
||||
source: null,
|
||||
};
|
||||
}
|
||||
|
||||
const componentHierarchy = getOwnerHierarchy(component);
|
||||
const instance = lastNotNativeInstance(componentHierarchy);
|
||||
const hierarchy = createHierarchy(componentHierarchy);
|
||||
|
||||
Reference in New Issue
Block a user