Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6212

REACT-NATIVE NativeTouchEvent event.target Event Bubbling

$
0
0

Hi there I have been looking for a way to allow bubbling of certain events to items that are exposed in this.props.children im sure there must be a simple way to do this with React-native?

private onTouchEvent(name, ev): void {    const event: NativeTouchEvent = ev.nativeEvent;    if(event.pageY - this.pageYStart < -50){        console.log(GESTURE_EVENTS.SWIPE_UP);    } else if(event.pageY - this.pageYStart > 50){        console.log(GESTURE_EVENTS.ON_PRESS);        ///event.target === 1893        /// here I want to call a method on or event    } }

Iv also found there is a way to expose native events which I assume can be used to target native elements. However ideally I would just like to use the target ID to find the element and execute a function call but see that with react-native arch this might not be easily achieved.

#import <React/RCTComponent.h>@interface GestureEmitter : UIView@property (nonatomic, copy) RCTBubblingEventBlock myCallback;@end@implementation GestureEmitter    ...- (void) onButtonPress {  self.myCallback(@{ data: 'data sent from native' });}    ...@end

Any help or advice would be greatly received.

Brndn


Viewing all articles
Browse latest Browse all 6212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>