
Vertical Step indicator
May 06, 2023
1 min
React Native Easy Toast is a library for displaying toast notifications in React Native applications. Toast notifications are non-intrusive messages that appear on the screen to provide users with feedback or information about a specific action. The library is lightweight and easy to use, making it a popular choice among React Native developers.
React Native Easy Toast offers several features that make it a powerful library for displaying toast notifications in React Native applications. Some of the notable features include:
| Props | Type | Optional | Default | Description |
|---|---|---|---|---|
| style | View.propTypes.style | true | {backgroundColor: ‘black’,opacity: OPACITY,borderRadius: 5,padding: 10,} | Custom style toast |
| position | PropTypes.oneOf([‘top’,‘center’,‘bottom’,]) | true | ‘bottom’ | Custom toast position |
| positionValue | React.PropTypes.number | true | 120 | Custom toast position value |
| fadeInDuration | React.PropTypes.number | true | 500 | Custom toast show duration |
| fadeOutDuration | React.PropTypes.number | true | 500 | Custom toast close duration |
| opacity | React.PropTypes.number | true | 1 | Custom toast opacity |
| textStyle | View.propTypes.style | true | {color:‘white’} | Custom style text |
| Method | Type | Optional | Description |
|---|---|---|---|
| show(text, duration, callback, onPress) | function | false | show a toast,unit is millisecond,and do callback |
| close() | function | - | start the close timer |
npm i react-native-easy-toast --save
Or
yarn add react-native-easy-toast
import React, {Component} from 'react';
import {
Button,
StyleSheet,
Text,
View,
} from 'react-native';
import Toast, {DURATION} from 'react-native-easy-toast'
export default class ToastTest extends Component {
constructor(props) {
super(props);
this.state = {
position: 'bottom',
style: {},
}
}
onClick(text, position, duration, withStyle) {
this.setState({
position: position,
})
if (withStyle) {
this.toastWithStyle.show(text, duration);
} else {
this.toast.show(text, duration);
}
}
getButton(text, position, duration, withStyle) {
return (
<Button
style={{padding: 10}}
onPress={() => this.onClick(text, position, duration, withStyle)}
title={text}
/>
)
}
render() {
return (
<View style={styles.container}>
{this.getButton('LENGTH_SHORT+top', 'top', DURATION.LENGTH_SHORT)}
{this.getButton('LENGTH_SHORT+bottom', 'bottom', DURATION.LENGTH_SHORT)}
{this.getButton('LENGTH_LONG+top', 'top', 2000)}
{this.getButton('LENGTH_LONG+bottom', 'bottom', 2000)}
{this.getButton('LENGTH_LONG+bottom+custom style', 'bottom', 2000, true)}
<Toast ref={(toast) => this.toast = toast} position={this.state.position}/>
<Toast ref={(toast) => this.toastWithStyle = toast} style={{backgroundColor: 'red'}}
position={this.state.position}/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex:1,
justifyContent: 'center',
alignItems: 'center',
},
});
Coming Soon…
Quick Links
Legal Stuff





