I'm trying to pass the following function into a child component as a prop, along with a string parameter:
navigateToDetailsPage(nasaId: string) { this.props.navigation.navigate('Details', { nasaId: nasaId })}
I pass in the function & parameter into the child component like so:
<NasaImage onPress={this.navigateToDetailsPage(result.data[0].nasa_id)} .../>
In the child component NasaImage I have declared onPress as:
onPress: () => void
However, I am getting the following error in the parent component:
Type 'void' is not assignable to type '() => void'.ts(2322)NasaImage.tsx(12, 3): The expected type comes from property 'onPress'