ptomasroos / react-native-tab-navigator

A tab bar that switches between scenes, written in JS for cross-platform support
MIT License
2.4k stars 416 forks source link

how to set icon? #118

Closed RodrigoRMG closed 7 years ago

RodrigoRMG commented 7 years ago

Hi, I can´t set an icon for each tab this is my code:

<TabNavigator.Item selected={this.state.selectedTab === 'dashboard'} title="Dashboard" renderIcon={() => \<Image source={{uri: iconDashboard}} />} renderSelectedIcon={() => \<Image source={{uri: iconDashboard}} />} onPress={() => this.setState({ selectedTab: 'dashboard' })}>

    </TabNavigator.Item>

Any help?

kadzier commented 7 years ago

Having this exact same issue too my image definitely exists and can be displayed elsewhere but when I set it inside renderIcon{} and renderSelectedIcon{} it still shows blank for that tab.

kadzier commented 7 years ago

Just figured this one out... you have to actually return the element in your function, using the return() keyword.

So changing my function to:

renderIcon = {() => { return( < Image source={...} / > ) }}

worked for me.