question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

<Touchable*> styling is not compatible with React Native Touchables

See original GitHub issue

RNGH Touchables have a different behavior from RN Touchables when styling — making them not drop-in compatible.

Take for example:

this is the behavior of RN TouchableOpacity (and of RNGH BaseButton):

Captura de pantalla 2019-05-14 11 02 45

this is the behavior of RNGH touchables:

Captura de pantalla 2019-05-14 11 03 01

the yellow box is a touchable with flex: 1.

The problem is that all RNGH Touchables render two wrapped views:

https://github.com/kmagiera/react-native-gesture-handler/blob/baf2ba72ea4fca22a11b507cffb4ee94f0126480/touchables/GenericTouchable.js#L258-L266

The styles are applied to the child view, so applying flex: 1 doesn’t do what one would expect.

I think the only way to avoid this incompatibility is to render just one native view. This should also be a little more performant.

I’m willing to help with implementation (at least on JS+iOS side), but I would need some basic pointers as to how to make RawButton accept View props…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:38
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
mjarrayacommented, Mar 2, 2020

If not fixed, this needs at minimum to be mentioned in the docs

10reactions
njdancercommented, Nov 26, 2019

@radex #854 is not exactly what you’ve proposed but does allow for a workaround.

In my use case, supplying ‘’‘containerStyle={{ flex: 1 }}’‘’ to an RNGH Touchable along with my existing ‘’‘style’‘’ prop, mirrors the native behaviour.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling Touches - React Native
Touchables ​. If the basic button doesn't look right for your app, you can build your own button using any of the "Touchable"...
Read more >
React native TouchableOpacity onPress not working on Android
In terms of hierarchy, I had a View within a Touchable Opacity; I was adding positioning to the View while assuming that Touchable...
Read more >
React Native touchable vs. pressable components
As a solution, React Native introduced touchable components to create custom-styled, cross-platform buttons. Before discussing touchable ...
Read more >
4 Different Type of React Native Touchables
No. Touchable, Available For. 1. TouchableNativeFeedback, Only For Android. 2. TouchableHighlight, For Android/IOS Both. 3 ...
Read more >
Pressable vs. Touchable in React Native | by MahYar - Medium
Touchable Component: 1. It includes the styles and effects that do not meet the platform interactions. 2. It does not support high-quality ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found