Files
bsky-social-app/src/view/com/util/EventStopper.tsx
T
Samuel Newman 3e2c181c40 Upgrade @types/react to 19 and run codemod (attempt 2) (#8918)
* update dependencies

* rm `import type React from 'react'`

* run codemods

* patch discord types

* update types/react-dom

* Update yarn.lock
2025-09-09 08:09:10 -07:00

33 lines
691 B
TypeScript

import {View, type ViewStyle} from 'react-native'
/**
* This utility function captures events and stops
* them from propagating upwards.
*/
export function EventStopper({
children,
style,
onKeyDown = true,
}: React.PropsWithChildren<{
style?: ViewStyle | ViewStyle[]
/**
* Default `true`. Set to `false` to allow onKeyDown to propagate
*/
onKeyDown?: boolean
}>) {
const stop = (e: any) => {
e.stopPropagation()
}
return (
<View
onStartShouldSetResponder={_ => true}
onTouchEnd={stop}
// @ts-ignore web only -prf
onClick={stop}
onKeyDown={onKeyDown ? stop : undefined}
style={style}>
{children}
</View>
)
}