From e94852ff286f306b0a9d26fffb50f7743f6aa9c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 10 Jun 2024 08:28:45 -0700 Subject: [PATCH] Modify IntersectionObserver example in RNTester to showcase changes in intersection due to changes in layout, instead of scroll (#44823) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44823 Changelog: [internal] This modifies the example for `IntersectionObserver` in RNTester to test that the API reports changes in intersection also coming from changes in layout (previously is was only from changes in scroll position). Reviewed By: javache Differential Revision: D58260057 fbshipit-source-id: 305d5996148730d718da30896f6cc62991b717f7 --- .../IntersectionObserverMDNExample.js | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverMDNExample.js b/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverMDNExample.js index 794a20f67abd6a..2aac729fcb4eee 100644 --- a/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverMDNExample.js +++ b/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverMDNExample.js @@ -17,7 +17,7 @@ import { useRef, useState, } from 'react'; -import {ScrollView, StyleSheet, Text, View} from 'react-native'; +import {Button, ScrollView, StyleSheet, Text, View} from 'react-native'; export const name = 'IntersectionObserver MDN Example'; export const title = name; @@ -33,25 +33,35 @@ export function render(): React.Node { */ function IntersectionObserverMDNExample(): React.Node { const theme = useContext(RNTesterThemeContext); + const [showMargin, setShowMargin] = useState(true); return ( +