# react-native-outside-press

> airbnb/react-outside-click-handler but for React Native

Latest version **1.2.2** (published 2024-01-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-outside-press
pnpm add react-native-outside-press
yarn add react-native-outside-press
bun add react-native-outside-press
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2024-01-02 |
| First published | 2022-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 49.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 145 |
| Author | David Angulo |
| Maintainers | dcangulo |
| Keywords | react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-outside-press
- Repository: https://github.com/dcangulo/react-native-outside-press
- Homepage: https://github.com/dcangulo/react-native-outside-press#readme
- Issues: https://github.com/dcangulo/react-native-outside-press/issues
- npm.io page: https://npm.io/package/react-native-outside-press

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2024-01-02
- 1.2.1 — 2023-08-19
- 1.2.0 — 2023-08-14
- 1.1.0 — 2022-08-10
- 1.0.2 — 2022-07-12
- 1.0.1 — 2022-07-10
- 1.0.0 — 2022-07-10

## README

# React Native Outside Press
[![Package version](https://img.shields.io/npm/v/react-native-outside-press?style=for-the-badge&labelColor=000000)](https://www.npmjs.com/package/react-native-outside-press)
[![MIT license](https://img.shields.io/badge/License-MIT-brightgreen.svg?style=for-the-badge&labelColor=000000)](LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-hotpink.svg?style=for-the-badge&labelColor=000000)](https://github.com/dcangulo/react-native-outside-press/pulls)

[airbnb/react-outside-click-handler](https://github.com/airbnb/react-outside-click-handler) but for React Native.

## Compatibility
| iOS                | Android            | Web                | Windows            | macOS              | Expo               |
|--------------------|--------------------|--------------------|--------------------|--------------------|--------------------|
| :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |

## Installation
```bash
yarn add react-native-outside-press
```

## Usage

### EventProvider
Wrap your app with `EventProvider`.

```js
import { EventProvider } from 'react-native-outside-press';

export default function App() {
  return (
    <EventProvider>
      <RestOfYourApp />
    </EventProvider>
  );
}
```

#### Props

| Name        | Description         | Type                                                       | Default       | Required? |
|-------------|---------------------|------------------------------------------------------------|---------------|-----------|
| `style`     |                     | [ViewStyle](https://reactnative.dev/docs/view-style-props) | `{ flex: 1 }` | `false`   |
| `ViewProps` | Inherits ViewProps. | [ViewProps](https://reactnative.dev/docs/view#props)       |               | `false`   |

### OutsidePressHandler
Wrap every component you want to detect outside press with `OutsidePressHandler`.

```js
import { View } from 'react-native';
import OutsidePressHandler from 'react-native-outside-press';

export default function MyComponent() {
  return (
    <OutsidePressHandler
      onOutsidePress={() => {
        console.log('Pressed outside the box!');
      }}
    >
      <View style={{ height: 200, width: 200, backgroundColor: 'black' }} />
    </OutsidePressHandler>
  );
}
```

#### Props

| Name             | Description                                          | Type                                                 | Default       | Required? |
|------------------|------------------------------------------------------|------------------------------------------------------|---------------|-----------|
| `onOutsidePress` | Function to run when pressed outside of component.   | function                                             |               | `true`    |
| `disabled`       | Controls whether `onOutsidePress` should run or not. | boolean                                              | `false`       | `false`   |
| `ViewProps`      | Inherits ViewProps.                                  | [ViewProps](https://reactnative.dev/docs/view#props) |               | `false`   |

## Changelogs
See [CHANGELOGS.md](CHANGELOGS.md)

## License
Copyright © 2023 David Angulo, released under the MIT license, see [LICENSE](LICENSE).

---
_Source: https://npm.io/package/react-native-outside-press · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
