Skip to content

Commit 9bc3694

Browse files
lunaleapszoontek
authored andcommitted
error if IntersectionObserver missing (facebook#55862)
Summary: Pull Request resolved: facebook#55862 Changelog: [Internal] - Error instead of warn if IntersectionObserver used with TurboModule being null Reviewed By: javache Differential Revision: D92873739 fbshipit-source-id: 987adce4b88894062ba6ef00a7925ecf71a972a7
1 parent b9c6970 commit 9bc3694

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

packages/react-native/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import type IntersectionObserverEntry from '../IntersectionObserverEntry';
2626
import type {NativeIntersectionObserverToken} from '../specs/NativeIntersectionObserver';
2727

2828
import * as Systrace from '../../../../../Libraries/Performance/Systrace';
29-
import warnOnce from '../../../../../Libraries/Utilities/warnOnce';
3029
import {
3130
getInstanceHandle,
3231
getNativeNodeReference,
@@ -123,7 +122,7 @@ export function observe({
123122
target: ReactNativeElement,
124123
}): boolean {
125124
if (NativeIntersectionObserver == null) {
126-
warnNoNativeIntersectionObserver();
125+
throwIfNoNativeIntersectionObserver();
127126
return false;
128127
}
129128

@@ -187,7 +186,7 @@ export function unobserve(
187186
target: ReactNativeElement,
188187
): void {
189188
if (NativeIntersectionObserver == null) {
190-
warnNoNativeIntersectionObserver();
189+
throwIfNoNativeIntersectionObserver();
191190
return;
192191
}
193192

@@ -232,7 +231,7 @@ function notifyIntersectionObservers(): void {
232231

233232
function doNotifyIntersectionObservers(): void {
234233
if (NativeIntersectionObserver == null) {
235-
warnNoNativeIntersectionObserver();
234+
throwIfNoNativeIntersectionObserver();
236235
return;
237236
}
238237

@@ -283,9 +282,6 @@ function doNotifyIntersectionObservers(): void {
283282
}
284283
}
285284

286-
function warnNoNativeIntersectionObserver() {
287-
warnOnce(
288-
'missing-native-intersection-observer',
289-
'Missing native implementation of IntersectionObserver',
290-
);
285+
function throwIfNoNativeIntersectionObserver() {
286+
throw new Error('Missing native implementation of IntersectionObserver');
291287
}

0 commit comments

Comments
 (0)