In React Native, most "buttons" are actually implemented using Touchable components.
Button, these components support an
onPress prop. However, unlike
Button, these components support custom styling - essentially a Touchable is a
View that can be pressed.
Touchables have a variety of other props, like
onPressOut, which give us more control over the behavior of the button. We can use these props to run custom animations. We'll cover custom animations later in the animation section.
Kinds of Touchable
Although we can run custom animations, most of the time, we use one of 2 built-in animations: a fade in opacity, or a change of color. There are preconfigured touchable components for each of these:
If we do want to write a custom animation, we'll typically use
TouchableWithoutFeedback, since it doesn't have any built-in animation. If we want to support the native Android "ripple" effect, we'll use
Want to learn React Native in-depth?