Customizable toast-like notifications for React Native
npm install react-native-notification
$ npm install react-native-notification
`Usage
`javascript
import React, { Component, View, Text, TouchableOpacity, StyleSheet } from 'react-native';
import Notification from 'react-native-notification';class MyComponent extends Component {
constructor() {
this.state = {
message: '',
};
}
onPress = () => {
this.setState({
message: 'Hi there',
});
};
render() {
return (
Tap me!
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
text: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
});
export default MyComponent;
`$3
The styles of the notification are exposed as Notification.styles. The container property describes the notification container (by default the rounded gray-ish rectangle) and the message property the message itself (the white color text).What may be in store for future versions
- Allow message as props.children allowing other components to be part of the message
- More unit testsLicense
MIT (See LICENSE`)