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

How to use this.props.navigation.openDrawer () in a class component without having to pass props to it from parent?

$
0
0

I have this component:

class HeaderBar extends Component<Props> {    render() {        return (<View style={stylesHeaderBar.header}><View style={stylesHeaderBar.menuIconContainer}><Icon name='menu' onPress={() => this.props.navigation.openDrawer()} /></View><View style={stylesHeaderBar.titleAndLogoContainer}><Image style={stylesHeaderBar.image} source={require('../../assets/icon.png')} /><Text> Restaurantes </Text></View></View>        )    }}

And I want to call it from my main file like this:

<HeaderBar/>

But he forces me to pass him like this:

<HeaderBar navigation={}> </HeaderBar>

I'm new to React and I don't have much idea how it works, how can I fix it? I am using typscript.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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