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

Why am I getting "TypeError: onSelect is not a function."?

$
0
0

I am passing data from a child component to its parent via a prop which is assigned to a button.

Code below:

Parent component

const Parent:React.FC<Props> = (props) =>{return (<View> <LocationPicker         onSelect={(e,region)=>handleConfirm(region)} />    </View>    )}

Child component:

interface LocationPickerProps {  onSelect:(event:GestureResponderEvent,region: Region)=>void;}export const LocationPicker: React.FC<LocationPickerProps> = ({onSelect}) => {    const region:Region = {...}  return(<LargeButton onPress={(e)=>onSelect(e,region)}>SELECT LOCATION</LargeButton>    )}

The error I get is TypeError: onSelect is not a function. (In 'onSelect(e, region)', 'onSelect' is undefined)

What am I doing wrong?


Viewing all articles
Browse latest Browse all 6291

Trending Articles



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