1.2.2 • Published 4 months ago

react-native-outside-press v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

React Native Outside Press

Package version MIT license PRs Welcome

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

Compatibility

iOSAndroidWebWindowsmacOSExpo
:white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark::white_check_mark:

Installation

yarn add react-native-outside-press

Usage

EventProvider

Wrap your app with EventProvider.

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

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

Props

NameDescriptionTypeDefaultRequired?
styleViewStyle{ flex: 1 }false
ViewPropsInherits ViewProps.ViewPropsfalse

OutsidePressHandler

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

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

NameDescriptionTypeDefaultRequired?
onOutsidePressFunction to run when pressed outside of component.functiontrue
disabledControls whether onOutsidePress should run or not.booleanfalsefalse
ViewPropsInherits ViewProps.ViewPropsfalse

Changelogs

See CHANGELOGS.md

License

Copyright © 2023 David Angulo, released under the MIT license, see LICENSE.

1.2.2

4 months ago

1.2.0

9 months ago

1.2.1

9 months ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago