React Native library to detect clicks outside the component 👆

Overview

react-native-click-outside

React Native library to detect clicks outside the component 👆

Build status - typescript compile License badge Latest, released version Date of latest commit

🪄 Installation

yarn add react-native-click-outside

📖 Usage

First of all, you need to wrap your app with ClickOutsideProvider as high as possible, for example in App.tsx:

import { ClickOutsideProvider } from 'react-native-click-outside';

export const App = () => (
  <ClickOutsideProvider>
    { /* rest of your app */ }
  </ClickOutsideProvider>
);

Then you can call useClickOutside hook to detect clicks outside the component. First argument is the function that will be called every time user clicks outside of this component. It returns ref that you need to attach to the component you want to detect clicks outside of. For example:

import { useClickOutside } from 'react-native-click-outside';

export default function MyComponent() {
  const ref = useClickOutside<View>(() => console.log('clicked outside A'));
  return (
    <View ref={ref}>
      <Text>Test</Text>
    </View>
  );
}

⚖️ License

MIT

📝 Contribute

See the contributing guide to learn how to contribute to the repository and the development workflow.

Built with ♥️ by Jakub Grzywacz

You might also like...
Alarm clock functionality for react native ios and android using react-native-push-notification and react-native-community/async-storage
Alarm clock functionality for react native ios and android using react-native-push-notification and react-native-community/async-storage

react-native-simple-alarm Alarm clock functionality for react native ios and android built using react-native-push-notification and react-native-commu

A library to access system setting, and change it easily. eg: volume, brightness, wifi
A library to access system setting, and change it easily. eg: volume, brightness, wifi

react-native-system-setting It provides some system setting APIs for you. Support iOS and Android both. Support Volume ( with listener) Brightness Wif

React Native component for getting or setting clipboard content

NOTE: Clipboard API has been part of RN core since version 0.17, https://github.com/facebook/react-native/blob/master/Libraries/Components/Clipboard/C

React Native Component to create individual character inputs for quiz-like interfaces, OTP screens etc.
React Native Component to create individual character inputs for quiz-like interfaces, OTP screens etc.

react-native-quiz-input Basic Demo Description react-native-quiz-input is a React-Native package that allows the creation of individual character text

Fully customizable, easy to use checkbox with flexible component by React Native on Android and iOS
Fully customizable, easy to use checkbox with flexible component by React Native on Android and iOS

Installation Add the dependency: npm i react-native-checkbox-flex Peer Dependencies IMPORTANT! You need install them "@freakycoder/react-native-bounce

React Native CallKit utilises a brand new iOS 10 framework CallKit to make the life easier for VoIP developers using React Native.

React Native CallKit utilises a brand new iOS 10 framework CallKit to make the life easier for VoIP developers using React Native.

React-native-wordle - A simple re-implementation of wordle using react native

react native wordle A simple re-implementation of wordle. guess the randomly cho

React-native-esbuild: The fastest bundler for React Native

Fast bundler and dev server for react-native using esbuild

React Native Firebase Authentication Starter, manage user authentication in React Native app with firebase

Sign up and sign in screens for mobile using React Native. This is an example of how to use Firebase Authentication in React Native application, how to let users create an account or log in to an existing account.

Releases(v0.1.0-alpha.0)
Owner
Jakub Grzywacz
Jakub Grzywacz
React Native Library for OneSignal Push Notifications Service

React Native OneSignal SDK OneSignal is a free push notification service for mobile apps. This SDK makes it easy to integrate your native React-Native

OneSignal 1.5k Dec 28, 2022
A library for React-Native to help you download large files on iOS and Android both in the foreground and most importantly in the background.

react-native-background-downloader A library for React-Native to help you download large files on iOS and Android both in the foreground and most impo

Eko Labs 271 Dec 27, 2022
Free React Native library to display local notifications.

React-Native NotiFREE ⚛ React Native library to display local notifications. A FREE alternative to React Native NotiFEE. Why? Nobody can remove the gr

Douglas Nassif Roma Junior 23 Nov 10, 2022
Rising Imaged Card View with Awesome Shadows and Fully Customizable Library for React Native

Installation Add the dependency: React Native: npm i react-native-imaged-card-view Peer Dependencies IMPORTANT! You need install them. "react": ">= 16

FreakyCoder 17 Dec 14, 2022
React Native benchmarking library inspired by benchmark.js and written in TypeScript.

react-native-benchmark React Native benchmarking library inspired by benchmark.js and written in TypeScript. Warning: This library is work in progess.

Eugene Hauptmann 4 Oct 19, 2021
React Native library for PSPDFKit for iOS, Android and Windows UWP.

React Native Library for PSPDFKit for iOS, Android & Windows UWP. (PDF SDK for React Native) This library requires a valid license of PSPDFKit. Licens

PSPDFKit GmbH 120 Dec 14, 2022
☁️🎨 An experimental universal, customizable styling and animation library for React Native. (beta)

An experimental universal, customizable styling and animation library for React Native. Why? ⎯ Features ⎯ Website ⎯ Documentation ⎯ Get Started ⎯ Exam

SkyleJS 24 Apr 14, 2022
A react-native library to secure api credentials(URL, Key, Secret) from exposing to source control and bundle in apk files.

A react-native library to secure api credentials(URL, Key, Secret) from exposing to source control and bundle in apk files.

Samyak Agrawal 3 Jun 24, 2022
VS Code Extension allows splitting React Native Component into Sub-Component

VS Code Extension allows splitting React Native Component into Sub-Component

Numan 33 Jun 20, 2022
A barcode scanner component for react native - not maintained anymore - use react-native-camera

react-native-barcodescanner - not maintained anymore - use react-native-camera Version 0.4.0 of react-native-camera includes barcode scanning for andr

Idea Creation / E-GUMA 540 Oct 31, 2022