From c26dbe286068354379859b525d03fdd74df060da Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Mon, 2 Mar 2026 16:32:49 -0800 Subject: [PATCH] error if IntersectionObserver missing (#55862) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55862 Changelog: [Internal] - Error instead of warn if IntersectionObserver used with TurboModule being null Reviewed By: javache Differential Revision: D92873739 fbshipit-source-id: 987adce4b88894062ba6ef00a7925ecf71a972a7 --- .../internals/IntersectionObserverManager.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/react-native/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js b/packages/react-native/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js index edd4d3c06e6..7e69617b1d6 100644 --- a/packages/react-native/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +++ b/packages/react-native/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js @@ -26,7 +26,6 @@ import type IntersectionObserverEntry from '../IntersectionObserverEntry'; import type {NativeIntersectionObserverToken} from '../specs/NativeIntersectionObserver'; import * as Systrace from '../../../../../Libraries/Performance/Systrace'; -import warnOnce from '../../../../../Libraries/Utilities/warnOnce'; import { getInstanceHandle, getNativeNodeReference, @@ -123,7 +122,7 @@ export function observe({ target: ReactNativeElement, }): boolean { if (NativeIntersectionObserver == null) { - warnNoNativeIntersectionObserver(); + throwIfNoNativeIntersectionObserver(); return false; } @@ -187,7 +186,7 @@ export function unobserve( target: ReactNativeElement, ): void { if (NativeIntersectionObserver == null) { - warnNoNativeIntersectionObserver(); + throwIfNoNativeIntersectionObserver(); return; } @@ -232,7 +231,7 @@ function notifyIntersectionObservers(): void { function doNotifyIntersectionObservers(): void { if (NativeIntersectionObserver == null) { - warnNoNativeIntersectionObserver(); + throwIfNoNativeIntersectionObserver(); return; } @@ -283,9 +282,6 @@ function doNotifyIntersectionObservers(): void { } } -function warnNoNativeIntersectionObserver() { - warnOnce( - 'missing-native-intersection-observer', - 'Missing native implementation of IntersectionObserver', - ); +function throwIfNoNativeIntersectionObserver() { + throw new Error('Missing native implementation of IntersectionObserver'); }