Skip to content

Commit

Permalink
Guard against reused fibers in React Native commands (#21837)
Browse files Browse the repository at this point in the history
  • Loading branch information
yungsters committed Jul 8, 2021
1 parent c549bc4 commit 84639ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
22 changes: 10 additions & 12 deletions packages/react-native-renderer/src/ReactFabric.js
Expand Up @@ -160,16 +160,14 @@ function dispatchCommand(handle: any, command: string, args: Array<any>) {
'native component. Use React.forwardRef to get access to the underlying native component',
);
}

return;
}

if (handle._internalInstanceHandle) {
nativeFabricUIManager.dispatchCommand(
handle._internalInstanceHandle.stateNode.node,
command,
args,
);
if (handle._internalInstanceHandle != null) {
const {stateNode} = handle._internalInstanceHandle;
if (stateNode != null) {
nativeFabricUIManager.dispatchCommand(stateNode.node, command, args);
}
} else {
UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
}
Expand All @@ -186,11 +184,11 @@ function sendAccessibilityEvent(handle: any, eventType: string) {
return;
}

if (handle._internalInstanceHandle) {
nativeFabricUIManager.sendAccessibilityEvent(
handle._internalInstanceHandle.stateNode.node,
eventType,
);
if (handle._internalInstanceHandle != null) {
const {stateNode} = handle._internalInstanceHandle;
if (stateNode != null) {
nativeFabricUIManager.sendAccessibilityEvent(stateNode.node, eventType);
}
} else {
legacySendAccessibilityEvent(handle._nativeTag, eventType);
}
Expand Down
21 changes: 10 additions & 11 deletions packages/react-native-renderer/src/ReactNativeRenderer.js
Expand Up @@ -160,12 +160,11 @@ function dispatchCommand(handle: any, command: string, args: Array<any>) {
return;
}

if (handle._internalInstanceHandle) {
nativeFabricUIManager.dispatchCommand(
handle._internalInstanceHandle.stateNode.node,
command,
args,
);
if (handle._internalInstanceHandle != null) {
const {stateNode} = handle._internalInstanceHandle;
if (stateNode != null) {
nativeFabricUIManager.dispatchCommand(stateNode.node, command, args);
}
} else {
UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
}
Expand All @@ -182,11 +181,11 @@ function sendAccessibilityEvent(handle: any, eventType: string) {
return;
}

if (handle._internalInstanceHandle) {
nativeFabricUIManager.sendAccessibilityEvent(
handle._internalInstanceHandle.stateNode.node,
eventType,
);
if (handle._internalInstanceHandle != null) {
const {stateNode} = handle._internalInstanceHandle;
if (stateNode != null) {
nativeFabricUIManager.sendAccessibilityEvent(stateNode.node, eventType);
}
} else {
legacySendAccessibilityEvent(handle._nativeTag, eventType);
}
Expand Down

0 comments on commit 84639ab

Please sign in to comment.