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

using React Native prop onBackButtonPress?: () => void

$
0
0

What is the correct chain of actions to use my prop onBackButtonPress?: () => void; ?Right now typescript shows an error for the onPress -

Type '(() => void) | undefined' is not assignable to type '() => void'.  Type 'undefined' is not assignable to type '() => void'.

Do i need to type something completely different for the prop in my IconButton and app.tsx Header ?

type HeaderProps = {    onBackButtonPress?: () => void;};export function Header({ onBackButtonPress }}: HeaderProps) {    return (<View><IconButton onPress={onBackButtonPress} /></View>    );}

app.tsx file

<Header onBackButtonPress={() => null} />

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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