How to define a click area on a button with react native?

Flora

I'm currently developing an app using react native and I'm using react-navigation to navigate between screens, using buttons in my header (back arrow for example).

It's working well, however even if my icon is the right size it seems like the click area is really narrow and I struggle with it.

Do you know how I could define a click zone on my button for it to be clicked easier? I've tried the hitslop prop but it's not working for me (maybe it's been deprecated?).

Here is my button:

var backArrow =
  <TouchableOpacity onPress={() => this.props.navigation.goBack()}>
    <Ionicons name="ios-arrow-back" size={22} color="#ff8c00" />
  </TouchableOpacity>

I'm using Expo and testing on an iPhone 6s Plus.

Charles Salmon

Wrapping the Ionicons in a TouchableOpacity will only provide a clickable area as large as the Ionicons component. You can increase the size of the clickable area with the following structure:

<TouchableOpacity>
  <View>
    <Ionicons />
  </View>
</TouchableOpacity>

by styling the View to be as large as you require it.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive