React-native-gesture-handler: <Touchable*> styling is not compatible with React Native Touchables

Created on 14 May 2019  Â·  3Comments  Â·  Source: software-mansion/react-native-gesture-handler

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…

Important Touchable

Most helpful comment

any update on this ? @kmagiera @brentvatne

All 3 comments

any update on this ? @kmagiera @brentvatne

@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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jhalborg picture jhalborg  Â·  5Comments

enahum picture enahum  Â·  4Comments

jacobrosenskold picture jacobrosenskold  Â·  3Comments

alexthebake picture alexthebake  Â·  3Comments

rgangopadhya picture rgangopadhya  Â·  4Comments