react-native-popup-menu
Advanced tools
+6
-3
| { | ||
| "name": "react-native-popup-menu", | ||
| "version": "0.8.0", | ||
| "version": "0.8.1", | ||
| "description": "extensible popup/context menu for react native", | ||
@@ -28,3 +28,6 @@ "main": "src/index.js", | ||
| "testRegex": ".*-test.js", | ||
| "testPathIgnorePatterns": ["/node_modules/", "<rootDir>/examples/"], | ||
| "testPathIgnorePatterns": [ | ||
| "/node_modules/", | ||
| "<rootDir>/examples/" | ||
| ], | ||
| "moduleFileExtensions": [ | ||
@@ -59,6 +62,6 @@ "js" | ||
| "react": "^15.5.4", | ||
| "react-addons-test-utils": "^15.5.1", | ||
| "react-dom": "^15.5.4", | ||
| "react-test-renderer": "^15.6.1", | ||
| "sinon": "^2.2.0" | ||
| } | ||
| } |
+2
-0
| # react-native-popup-menu | ||
| [](https://www.npmjs.com/package/react-native-popup-menu) | ||
@@ -9,2 +10,3 @@ Extensible popup menu component for React Native for Android, iOS and (unofficially) UWP. | ||
| * By default opening and closing animations | ||
| * Optional back button handling | ||
| * Easy styling | ||
@@ -11,0 +13,0 @@ * Customizable on various levels - menu options, positioning, animations |
+40
-1
| import React, { Component } from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { View } from 'react-native'; | ||
| import { View, BackHandler } from 'react-native'; | ||
| import makeMenuRegistry from './menuRegistry'; | ||
@@ -37,2 +37,39 @@ import Backdrop from './Backdrop'; | ||
| _handleBackButton = () => { | ||
| const { backHandler } = this.props; | ||
| debug('_handleBackButton called', backHandler); | ||
| // Default handler if true is passed | ||
| if (backHandler === true) { | ||
| if (this.isMenuOpen()) { | ||
| this.closeMenu(); | ||
| return true; | ||
| } | ||
| } | ||
| // Custom handler called with MenuContext instance id function is passed | ||
| if (typeof backHandler === 'function') { | ||
| return backHandler(this); | ||
| } | ||
| return false; | ||
| } | ||
| componentDidMount() { | ||
| if (BackHandler) { | ||
| BackHandler.addEventListener('hardwareBackPress', this._handleBackButton); | ||
| } else { | ||
| const {backHandler} = this.props; | ||
| if (backHandler === true || typeof backHandler === 'function') { | ||
| console.warn('backHandler prop cannot be used if BackHandler is not present (RN >= 0.44 required)'); | ||
| } | ||
| } | ||
| } | ||
| componentWillUnmount() { | ||
| if (BackHandler) { | ||
| BackHandler.removeEventListener('hardwareBackPress', this._handleBackButton); | ||
| } | ||
| } | ||
| isMenuOpen() { | ||
@@ -242,2 +279,3 @@ return !!this.state.openedMenu; | ||
| customStyles: PropTypes.object, | ||
| backHandler: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]), | ||
| } | ||
@@ -247,2 +285,3 @@ | ||
| customStyles: {}, | ||
| backHandler: false, | ||
| }; | ||
@@ -249,0 +288,0 @@ |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
34057
3.93%920
3.72%82
2.5%