Pressable
Pressable wraps components to add interactivity with rendering a UI element. Wrap small UI elements in Pressable to perform actions that don’t fit Button or Link.
optional = ?
Name | Type | Description |
---|---|---|
onPress | () => void |
Callback for the pressable. |
- 📱 All children of Pressables are placed in a single view object, which makes recycling the views expensive. Consider keeping your Pressable simple.
- 📱 Do not nest Layouts within Pressable. This will result in unintended behavior
- Do not nest other Action components (Button, Link) within Pressable. This will result in unexpected behavior.
- 📱 A child of Pressable with
onPress
will take precedence and not call Pressable'sonPress
- 🖥 Both the child of Pressable with
onPress
and Pressable'sonPress
will activate if the child is pressed.
- 📱 A child of Pressable with
✅ Do | 🛑 Don't |
---|---|
📱 Keep Pressable shallow. Complex hierarchies have performance penalties | Wrap Button or Link |
Wrap small UI elements in Pressable to perform actions that don’t fit Button or Link. | Wrap Layout components |