React Native Tutorial - 13 - Pressable
Vložit
- čas přidán 22. 07. 2023
- 📘 Courses - learn.codevolution.dev/
💖 Support UPI - support.codevolution.dev/
💖 Support Paypal - www.paypal.me/Codevolution
💾 Github - github.com/gopinav
📱 Follow Codevolution
+ Twitter - / codevolutionweb
+ Facebook - / codevolutionweb
📫 Business - codevolution.business@gmail.com
Pressable
React Native Tutorial
React Native Tutorial for Beginners
one small correction
order of events trigger
1.onPressIn
2.onPress
3.onPressOut
for long press
1.onPressIn
2.onLongPress
3.onPressOut
They are working as expected : )
That was helpful, thank you!
3:36
the correct flow is:
onPressIn => onPress => onPressOut
Also, is there any reason why you would use TouchableOpacity instead of Pressable or vice versa?
I noticed images can't handle onPress events but Text can. So, I guess with Text, you would only use Pressable when you're want an onPress event on more than one consecutive Text component at a time.
Bro! you have the react native dedicated playlist for this? I'm currently at EP 26 of your react js. im planning to proceed on native😊
There is!
How about TouchableOpacity and TouchableHighlight? Are these deprecated?
What’s difference between Pressable and TouchableOpacity please ? And which it’s preferable to use ?
In US we say same sh*t different toilet :)
TouchableOpacity is deprecated now by the official docs, they encourage to use Pressable now.
As far as I understood they are both basically the same, used to wrap around an element which is not usually pressable, but then you can press on it and attach a onPress event listener to Pressable and basically make any element pressable
The difference is that TouchableOpacity provide a out of the box opacity fading upon press (visual indication that you pressed the button), but Pressable does not provide any feedback.
Can we differentiate ios and android press
Yes, he says which one, the iOS and android. Also, the iOS button does not have a blue padding around it. Listen closely.
👍🙏
First
import React, { useState } from "react";
import { Pressable, View, Text } from "react-native";
const MyComponent = () => {
const [count, setCount] = useState(0);
const onPress = () => {
setCount(count + 1);
};
return (
Press Me
Count: {count}
)
}
export default MyComponent;
Jesse wtf are you talking about?
I tried