react-native-touch-outside
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

React Native Touch Outside

Utility library to handle outside touches in React Native

Installation

Installing touch-outside only takes a single command and you're ready to roll:

# with npm
npm install --save react-native-touch-outside

# with yarn
yarn add react-native-touch-outside

Usage

Wrap the TouchAreaProvider on the root of your app.

TouchAreaProvider

<TouchAreaProvider>
  <Screen />
</TouchAreaProvider>

touchOutside

A wrapper around any View-based component that registers the component for touchOutside events.

import { touchOutside } from "react-native-touch-outside";

const TouchOutsideView = touchOutside(View);

export const ExampleComponent = () => {
  function handleTouchOutside(id: string) {
    console.log("Pressed outside!");
  }

  return <TouchOutsideView onTouchOutside={handleTouchOutside} />;
};

TouchOutsideView

A convenience View component that registers the component for touchOutside events.

import { TouchOutsideView } from "react-native-touch-outside";

export const ExampleComponent = () => {
  function handleTouchOutside(id: string) {
    console.log("Pressed outside!");
  }

  return <TouchOutsideView onTouchOutside={handleTouchOutside} />;
};

TouchOutsidePressable

A convenience Pressable component that registers the component for touchOutside events.

import { TouchOutsidePressable } from "react-native-touch-outside";

export const ExampleComponent = () => {
  function handleTouchOutside(id: string) {
    console.log("Pressed outside!");
  }

  return <TouchOutsidePressable onTouchOutside={handleTouchOutside} />;
};

/react-native-touch-outside/

    Package Sidebar

    Install

    npm i react-native-touch-outside

    Weekly Downloads

    10

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    49 kB

    Total Files

    58

    Last publish

    Collaborators

    • fabianmeul