Skip to content

Commit a03db6e

Browse files
committed
Handle flow errors
1 parent d63319b commit a03db6e

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

packages/react-native-renderer/src/ReactFiberConfigFabric.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,12 @@ FragmentInstance.prototype.observeUsing = function (
647647
traverseFragmentInstance(this._fragmentFiber, observeChild, observer);
648648
};
649649
function observeChild(instance: Instance, observer: IntersectionObserver) {
650+
const publicInstance = getPublicInstance(instance);
651+
if (publicInstance == null) {
652+
throw new Error('Expected to find a host node. This is a bug in React.');
653+
}
650654
// $FlowFixMe[incompatible-call] Element types are behind a flag in RN
651-
observer.observe(getPublicInstance(instance));
655+
observer.observe(publicInstance);
652656
return false;
653657
}
654658
// $FlowFixMe[prop-missing]
@@ -669,8 +673,12 @@ FragmentInstance.prototype.unobserveUsing = function (
669673
}
670674
};
671675
function unobserveChild(instance: Instance, observer: IntersectionObserver) {
676+
const publicInstance = getPublicInstance(instance);
677+
if (publicInstance == null) {
678+
throw new Error('Expected to find a host node. This is a bug in React.');
679+
}
672680
// $FlowFixMe[incompatible-call] Element types are behind a flag in RN
673-
observer.unobserve(getPublicInstance(instance));
681+
observer.unobserve(publicInstance);
674682
return false;
675683
}
676684

@@ -693,8 +701,7 @@ export function commitNewChildToFragmentInstance(
693701
): void {
694702
if (fragmentInstance._observers !== null) {
695703
fragmentInstance._observers.forEach(observer => {
696-
// $FlowFixMe[incompatible-call] Element types are behind a flag in RN
697-
observer.observe(getPublicInstance(child));
704+
observeChild(child, observer);
698705
});
699706
}
700707
}

packages/react-reconciler/src/ReactFiberTreeReflection.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,19 +345,19 @@ export function doesFiberContain(
345345
return false;
346346
}
347347

348-
export function traverseFragmentInstance<A, B, C>(
348+
export function traverseFragmentInstance<I, A, B, C>(
349349
fragmentFiber: Fiber,
350-
fn: (Instance, A, B, C) => boolean,
350+
fn: (I, A, B, C) => boolean,
351351
a: A,
352352
b: B,
353353
c: C,
354354
): void {
355355
traverseFragmentInstanceChildren(fragmentFiber.child, fn, a, b, c);
356356
}
357357

358-
function traverseFragmentInstanceChildren<A, B, C>(
358+
function traverseFragmentInstanceChildren<I, A, B, C>(
359359
child: Fiber | null,
360-
fn: (Instance, A, B, C) => boolean,
360+
fn: (I, A, B, C) => boolean,
361361
a: A,
362362
b: B,
363363
c: C,

scripts/error-codes/codes.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,5 +543,6 @@
543543
"555": "Cannot requestFormReset() inside a startGestureTransition. There should be no side-effects associated with starting a Gesture until its Action is invoked. Move side-effects to the Action instead.",
544544
"556": "Expected prepareToHydrateHostActivityInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.",
545545
"557": "Expected to have a hydrated activity instance. This error is likely caused by a bug in React. Please file an issue.",
546-
"558": "Client rendering an Activity suspended it again. This is a bug in React."
546+
"558": "Client rendering an Activity suspended it again. This is a bug in React.",
547+
"559": "Expected to find a host node. This is a bug in React."
547548
}

0 commit comments

Comments
 (0)