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

Deprecate Touchables #2382

Closed
1 task done
necolas opened this issue Aug 28, 2022 · 11 comments
Closed
1 task done

Deprecate Touchables #2382

necolas opened this issue Aug 28, 2022 · 11 comments
Labels
enhancement Requires extension or creation of new React Native API has: pr Subject of a pull request project:react-native-web Issue associated with react-native-web

Comments

@necolas
Copy link
Owner

necolas commented Aug 28, 2022

Is there an existing request?

  • I have searched for this request

Describe the feature request

The Touchables are no longer recommended in React Native and have been replaced by Pressable. We should deprecate the Touchable components and mixin, and then remove them from React Native for Web. There has been the intent to deprecate them from React Native for a while, but the team hasn't had time to get around to it yet.

@necolas necolas added enhancement Requires extension or creation of new React Native API project:react-native-web Issue associated with react-native-web labels Aug 28, 2022
@necolas necolas added this to the 0.19: React 18 milestone Aug 28, 2022
@necolas necolas added the has: pr Subject of a pull request label Sep 1, 2022
necolas added a commit that referenced this issue Sep 1, 2022
These components have been replaced by Pressable and will be removed
from React Native.

Fix #2382
necolas added a commit that referenced this issue Sep 1, 2022
These components have been replaced by Pressable and will be removed
from React Native.

Fix #2382
necolas added a commit that referenced this issue Nov 28, 2022
These components have been replaced by Pressable and will be removed
from React Native.

Fix #2382
necolas added a commit that referenced this issue Dec 27, 2022
These components have been replaced by Pressable and will be removed
from React Native.

Fix #2382
@agusvazquez
Copy link

Hello @necolas are there any docs where I can learn about this?

I looked for TouchableOpacity, the official docs doesn't say that is getting deprecated or no longer recommended to use.
https://reactnative.dev/docs/touchableopacity

Thanks!

@nabilfreeman
Copy link

nabilfreeman commented Oct 10, 2023

@agusvazquez He seems to regularly deprecate things in RN Web ahead of core RN. I've encountered this twice now, pretty annoying.

Edit: But, you know, thanks for everything you do Nicolas, it's your library and you are appreciated 🙏

@gentlee
Copy link

gentlee commented Jan 13, 2024

@necolas I think It is a mistake. Pressable doesn't have press feedback by default, while TouchableOpacity does, and it works most of the time like a charm.

Pressable requires additional programming of the feedback, so if we remove TouchableOpacity, everyone will actually implement it out of Pressable, which sounds like an excess work for no good reason.

Also, by being not so flexible, TouchableOpacity seems to be a bit faster alternative.

TouchableWithoutFeedback probably can be deprecated as it looks like a duplicate or Pressable, but other components, especially TouchableOpacity, IMO should not.

@necolas
Copy link
Owner Author

necolas commented Jan 14, 2024

RN itself has long intended to deprecate those components but just hasn't gotten around to doing so. If you're targeting web, you'll have to move off old APIs faster, because the cost of RN bloat on web is far too high both for me to maintain and for apps on web to be vaguely acceptable from a perf perspective.

@agusvazquez
Copy link

agusvazquez commented Jan 15, 2024

Isn't the purpose of this library to provide compatibility with React Native? Meaning, code in React Native and export for web.

If you deprecate / remove TouchableOpacity you are literally breaking the main purpose of this library.

IMO, As a mobile developer, I just want to do React Native work and export to web. That means supporting TouchableOpacity.

@gentlee
Copy link

gentlee commented Jan 15, 2024

@necolas may be they had I don't know, but they didn't, and for a reason. As I said, Pressable is not a replace for TouchableOpacity, it is a more flexible component if you need more control, that's it. And I agree with @agusvazquez, lets keep RNW aa a library that supports web platform, which it is doing pretty well, without trying to predict the future.

@Josema
Copy link

Josema commented Feb 5, 2024

TouchableOpacity is deprecated. Please use Pressable.

What is the main motivation of this decision while react-native still support it?

@totallytotallyamazing
Copy link

This set up of Pressable is a good alternative to TouchableOpacity:

    <Pressable
        style={({ pressed }) => [
            { opacity: pressed ? 0.5 : 1.0, backgroundColor: '#2782fb', width: 210, padding: 10, borderRadius: 12 }
        ]}
        onPress={someFunction}
        >
        <View>
            <Text className="font-semibold text-center text-[#fff]">Press Me</Text>
        </View>
    </Pressable>

@mickadoua
Copy link

This set up of Pressable is a good alternative to TouchableOpacity:

    <Pressable
        style={({ pressed }) => [
            { opacity: pressed ? 0.5 : 1.0, backgroundColor: '#2782fb', width: 210, padding: 10, borderRadius: 12 }
        ]}
        onPress={someFunction}
        >
        <View>
            <Text className="font-semibold text-center text-[#fff]">Press Me</Text>
        </View>
    </Pressable>

yes, its a good start, but without animation
i found this exemple very helpful https://stackoverflow.com/a/77743947

@YuriiLutsykSPRO
Copy link

I think it was a wrong decision, but the library is awesome in general

@iamciro
Copy link

iamciro commented Sep 28, 2024

Hey there!

RN itself has long intended to deprecate those components but just hasn't gotten around to doing so. If you're targeting web, you'll have to move off old APIs faster, because the cost of RN bloat on web is far too high both for me to maintain and for apps on web to be vaguely acceptable from a perf perspective.

@necolas, do you have any source where the RN team suggests TouchableOpacity will be deprecated?

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requires extension or creation of new React Native API has: pr Subject of a pull request project:react-native-web Issue associated with react-native-web
Projects
None yet
Development

No branches or pull requests

9 participants