Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-native-easy-toast
Advanced tools
A react native module to show toast like android, it works on iOS and Android.
A react native module to show toast like android, it works on iOS and Android.
npm i react-native-easy-toast --save
yarn add react-native-easy-toast
import Toast, {DURATION} from 'react-native-easy-toast'
Add react-native-easy-toast
to your js file.
import Toast, {DURATION} from 'react-native-easy-toast'
Inside your component's render method, use Toast:
render() {
return (
<View>
...
<Toast ref={(toast) => this.toast = toast}/>
</View>
);
}
Note: Be sure to add
Toast
to the bottom of the root view.
Then you can use it like this:
this.toast.show('hello world!');
That's it, you're ready to go!
show a toast, and execute callback function when toast close it:
this.toast.show('hello world!', 500, () => {
// something you want to do at close
});
Show a toast forever until you manually close it:
this.toast.show('hello world!', DURATION.FOREVER);
Or pass an element:
this.toast.show(<View><Text>hello world!</Text></View>);
// later on:
this.toast.close('hello world!');
Optional you can pass a delay in seconds to the close()-method:
this.toast.close('hello world!', 500);
Currently, the default delay for close() in FOREVER-mode is set to 250 ms (or this.props.defaultCloseDelay, which you can pass with)
<Toast ... defaultCloseDelay={100} />
render() {
return (
<View>
<Button title={'Press me'} onPress={()=>{
this.toast.show('hello world!',2000);
}}/>
<Toast ref={(toast) => this.toast = toast}/>
</View>
);
}
render() {
return (
<View>
<Button title={'Press me'} onPress={()=>{
this.toast.show('hello world!',2000);
}}/>
<Toast
ref={(toast) => this.toast = toast}
style={{backgroundColor:'red'}}
position='top'
positionValue={200}
fadeInDuration={750}
fadeOutDuration={1000}
opacity={0.8}
textStyle={{color:'red'}}
/>
</View>
);
}
More Usage:
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 |
Issues are welcome. Please add a screenshot of bug and code snippet. Quickest way to solve issue is to reproduce it on one of the examples.
Pull requests are welcome. If you want to change API or making something big better to create issue and discuss it first.
MIT Licensed
FAQs
A react native module to show toast like android, it works on iOS and Android.
We found that react-native-easy-toast 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.