Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
radex opened this issue May 14, 2019 · 5 comments
Closed

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

radex opened this issue May 14, 2019 · 5 comments
Labels
Area: Touchable BugBash 31.03 Important This seem to be a serious issue and we will need to take a deeper look into it some time soon

Comments

@radex
Copy link

radex commented May 14, 2019

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…

@vi1199
Copy link

vi1199 commented Jul 3, 2019

any update on this ? @kmagiera @brentvatne

@njdancer
Copy link
Contributor

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

@mjarraya
Copy link

mjarraya commented Mar 2, 2020

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

@jakub-gonet jakub-gonet added Important This seem to be a serious issue and we will need to take a deeper look into it some time soon Area: Touchable labels Sep 3, 2020
@lukebars
Copy link
Contributor

Is there any progress on this one? Looks like crucial part of gesture handler's future, to be as consistent to react-native styling as possible.

@j-piasecki
Copy link
Member

containerStyle prop has been added to Gesture Handler's Touchables quite a while ago in #854. I'll close the issue because using that prop will solve the problem of not being able to style the outer view, and there is a lot of open issues regarding styling of Touchables and buttons coming from the same root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Touchable BugBash 31.03 Important This seem to be a serious issue and we will need to take a deeper look into it some time soon
Projects
None yet
Development

No branches or pull requests

8 participants