native_noob
native_noob

Reputation: 21

TouchableOpacity not working on ios

I have the following code:

<TouchableOpacity 
disabled={!this.state.canGoBack} 
onPress={this.onBack.bind(this)}>
<Icon 
   name="arrow-back" 
   style={this.state.canGoBack ? styles.iconStyleActive :
   styles.iconStyle}/>
</TouchableOpacity>

This works perfectly fine on Android. However, on iOS my app fails to load. I don't get any errors and activity indicator just keeps spinning. I tried without TouchableOpacity and the icons load fine.

Edit: Seems to also work if i replace Icons with Text then the touchable opacity works.

RN version: "react-native": "^0.45.1",

Upvotes: 1

Views: 4920

Answers (3)

user3107831
user3107831

Reputation: 85

It depends more on Icon styling. If you put Height/width const or set absolute position then TouchableOpacity is sometimes ineffective.

Try using flex and min max with height width.

Upvotes: 0

native_noob
native_noob

Reputation: 21

Issue seems resolved after deleting Node Modules folder and clearing cache. This seemed to have been a temporary fix, same issue occured when app was launched again without any changes to the code.

Upvotes: 1

HpDev
HpDev

Reputation: 2927

Just seen One more thing in Native Base and Found

They are using the ions according to Platfrom

<Icon ios='ios-menu' android="md-menu" style={{fontSize: 20, color: 'red'}}/>

May be this can Help you

Upvotes: 0

Related Questions