Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 856 Bytes

pressable.md

File metadata and controls

33 lines (25 loc) · 856 Bytes
id pressable
title Pressable
officialDoc https://reactnative.dev/docs/pressable

Pressable is a Core Component wrapper that can detect various stages of press interactions on any of it's defined children.

How it works

On an element wrapped by Pressable:

  1. onPressIn is called when a press is activated.
  2. onPressOut is called when the press gesture is deactivated.

You can read more about this on the official Pressable documentation.

Example

open ReactNative
open Style

@react.component
let make = () =>
  <Pressable
    onPress={_ => Console.log("Pressed")}
    style={({pressed}) =>
      s({backgroundColor: pressed ? "rgb(210, 230, 255)" : "white"})}>
    {({pressed}) =>
      <Text> {(pressed ? "Pressed!" : "Press Me")->React.string} </Text>}
  </Pressable>