Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class ReactNativeElement
offsetParentInstanceHandle,
);
// $FlowExpectedError[incompatible-type] The value returned by `getOffset` is always an instance handle for `ReadOnlyElement`.
const offsetParentElement: ReadOnlyElement = offsetParent;
const offsetParentElement: ReadOnlyElement | null = offsetParent;
return offsetParentElement;
}
}
Expand Down
14 changes: 9 additions & 5 deletions packages/react-native/Libraries/DOM/Nodes/ReadOnlyNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ export default class ReadOnlyNode {
return null;
}

return getPublicInstanceFromInternalInstanceHandle(parentInstanceHandle);
return (
getPublicInstanceFromInternalInstanceHandle(parentInstanceHandle) ?? null
);
}

get previousSibling(): ReadOnlyNode | null {
Expand Down Expand Up @@ -322,9 +324,11 @@ export function getChildNodes(
const childNodeInstanceHandles = nullthrows(
getFabricUIManager(),
).getChildNodes(shadowNode);
return childNodeInstanceHandles.map(instanceHandle =>
getPublicInstanceFromInternalInstanceHandle(instanceHandle),
);
return childNodeInstanceHandles
.map(instanceHandle =>
getPublicInstanceFromInternalInstanceHandle(instanceHandle),
)
.filter(Boolean);
}

function getNodeSiblingsAndPosition(
Expand All @@ -348,7 +352,7 @@ function getNodeSiblingsAndPosition(

export function getPublicInstanceFromInternalInstanceHandle(
instanceHandle: InternalInstanceHandle,
): ReadOnlyNode {
): ?ReadOnlyNode {
const mixedPublicInstance =
ReactFabric.getPublicInstanceFromInternalInstanceHandle(instanceHandle);
// $FlowExpectedError[incompatible-return] React defines public instances as "mixed" because it can't access the definition from React Native.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noformat
* @flow strict
* @nolint
* @generated SignedSource<<652b117c94307244bcf5e4af18928903>>
* @generated SignedSource<<1836a1b6639552dce12199ef2c85f63d>>
*/

import type {ElementRef, ElementType, Element, AbstractComponent} from 'react';
Expand Down Expand Up @@ -247,7 +247,7 @@ export type ReactFabricType = {
): ?Node,
getPublicInstanceFromInternalInstanceHandle(
internalInstanceHandle: InternalInstanceHandle,
): PublicInstance | PublicTextInstance,
): PublicInstance | PublicTextInstance | null,
...
};

Expand Down