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

ts error goes away when I use arrow function but come when I not use arrow

$
0
0

Why I get this error message:

Type '(message?: string | undefined) => void' is not assignable to type '(event: GestureResponderEvent) => void'.  Types of parameters 'message' and 'event' are incompatible.    Type 'GestureResponderEvent' is not assignable to type 'string'.ts(2322)

when I use the function like this:

<Button onPress={handleToggleModalMessage} style={[ButtonStyles.full, s.noneBorderTop]}><Text style={s.errorBtn}>Ok!</Text></Button>

But when I use this above function in this way then I dont get an ts error:

<Button onPress={() => handleToggleModalMessage()} style={[ButtonStyles.full, s.noneBorderTop]}><Text style={s.errorBtn}>Ok!</Text></Button>

can anyone explain me why?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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