/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict-local * @format */ import type {EventOccurrence} from './PointerEventSupport'; import type {PointerEvent} from 'react-native'; import {EventTracker} from './PointerEventSupport'; import * as React from 'react'; import {useState} from 'react'; import {Pressable, ScrollView, StyleSheet, Text, View} from 'react-native'; const eventsToTrack = ['onClick']; export default function PointerEventAccessibility(props: {}): React.MixedElement { const [eventsSeen, setEventsSeen] = useState>([]); const onAnyEvent = (occurrence: EventOccurrence, event: PointerEvent) => setEventsSeen(evs => evs.concat([occurrence])); return ( setEventsSeen(evs => evs.concat({eventName: 'onClick', id: 'pressable-parent'}), ) }> setEventsSeen(evs => evs.concat({eventName: 'onClick', id: 'pressable-child'}), ) }> setEventsSeen([])}> Reset events {eventsSeen.map((occurrence, ii) => ( {occurrence.id} {occurrence.eventName} ))} ); } const styles = StyleSheet.create({ topLevel: { display: 'flex', }, targetParent: { backgroundColor: 'red', display: 'flex', alignItems: 'center', justifyContent: 'center', height: 128, width: 128, }, eventsLog: { height: 300, }, clickableContainer: { display: 'flex', flexDirection: 'row', gap: 16, }, target: { backgroundColor: 'blue', height: 64, width: 64, }, targetPressable: { backgroundColor: 'yellow', height: 64, width: 64, }, reset: { margin: 10, fontSize: 30, borderColor: 'red', borderWidth: 1, textAlign: 'center', }, });