tsc is alerting me to add return types after the render method, and after onPress of my class component.
I've tried using React.ReactNode as the render return type, which makes the alert go away, but React.ReactChild also works (what's the difference? )
For the onPress event, i've tried void, which makes the return type happy, but I'm unsure if this is the correct return type to enter.
I've looked at the typescript cheatsheet on Github, but I can't find the opinionated definitive way.
export interface Props {
navigation;
}
class HomeScreen extends React.Component<Props> {
render(): React.ReactNode { // HERE
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
<Button title="Go to Details" onPress={(): void => this.props.navigation.navigate('Details')} /> // HERE
</View>
);
}
}