Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-native-back-android
Advanced tools
Readme
A Higher-order Component for handling back button press on React Native Android
npm install --save react-native-back-android
(Take Navigator as an example. Can be used in any scenario.)
import React, { Component } from 'react'
import { AppRegistry, Button, Text, View, Alert } from 'react-native'
import { StackNavigator } from 'react-navigation'
import backAndroid, {
hardwareBackPress,
exitApp
} from 'react-native-back-android'
class HomeScreen extends React.Component {
static navigationOptions = {
title: 'Welcome'
}
// reserved function for handling hardware back press
handleHardwareBackPress = () => {
Alert.alert(
'Quiting',
'Want to quit?',
[
{
text: 'Cancel',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel'
},
{ text: 'OK', onPress: () => exitApp() }
],
{ cancelable: false }
);
// return true to stop bubbling
return true
};
render () {
const { navigate } = this.props.navigation
return (
<View>
<Text>Hello, Chat App!</Text>
<Button onPress={() => navigate('Chat')} title='Chat with Lucy' />
</View>
)
}
}
class ChatScreen extends React.Component {
static navigationOptions = {
title: 'Chat with Lucy'
}
// reserved function for handling hardware back press
handleHardwareBackPress = () => {
const { goBack } = this.props.navigation
Alert.alert(
'Going Back',
'Want to go back?',
[
{
text: 'Cancel',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel'
},
{ text: 'OK', onPress: () => goBack() }
],
{ cancelable: false }
);
// return true to stop bubbling
return true
};
render () {
return (
<View>
<Text>Chat with Lucy</Text>
</View>
)
}
}
const ReactNativeBackAndroidExample = StackNavigator({
Home: { screen: hardwareBackPress(HomeScreen) },
Chat: { screen: hardwareBackPress(ChatScreen) }
})
AppRegistry.registerComponent('ReactNativeBackAndroidExample', () =>
backAndroid(ReactNativeBackAndroidExample)
)
Stateless component
...
import { hardwareBackPress } from 'react-native-back-android';
const Stateless = ({ navigator }) => (
<View>
<Text>Stateless</Text>
<Button
title="stateless"
onPress={() => {
navigator.pop();
}}
/>
</View>
);
const handleBackButtonPress = ({ navigation }) => {
navigation.goBack();
return true;
};
const EnhancedStateless = hardwareBackPress(Stateless, handleBackButtonPress);
export default EnhancedStateless;
FAQs
A Higher-order Component for handling back button press on React Native Android
The npm package react-native-back-android receives a total of 0 weekly downloads. As such, react-native-back-android popularity was classified as not popular.
We found that react-native-back-android demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.