react-native-easy-toast, 一款简单易用的 Toast 组件,支持 Android&iOS.

原文 原文链接地址

react-native-easy-toast
A react native module to show toast like android, it works on iOS and Android.

Content
. Installation
. Demo
. Getting started
. API
. Contribution

Installation
. 1.Run npm i react-native-easy-toast --save
. 2.import Toast, {DURATION} from 'react-native-toast-easy'

Demo
. Examples

Getting started
Add react-native-toast-easy to your js file.

import Toast, {DURATION} from ‘react-native-toast-easy’

Inside your component’s render method, use Toast:

render() {
         return (
             
                 ...
                 "toast"/>
             
         );
 }

Note: Add it in the bottom of the root view.

Then you can use it like this:

this.refs.toast.show('hello world!');

That’s it, you’re ready to go!

Basic usage

render() {
        return (
            <View style={styles.container}>
                <TouchableHighlight
                    style={{padding: 10}}
                    onPress={()=>{
                        this.refs.toast.show('hello world!');
                    }}>
                    <Text>Press meText>
                TouchableHighlight>
                <Toast ref="toast"/>
            View>
        );
    }

Custom Toast

render() {
        return (
            <View style={styles.container}>
                <TouchableHighlight
                    style={{padding: 10}}
                    onPress={()=>{
                        this.refs.toast.show('hello world!',DURATION.LENGTH_LONG);
                    }}>
                    <Text>Press meText>
                TouchableHighlight>
                <Toast 
                    ref="toast" 
                    style={{backgroundColor:'red'}} 
                    position='top'
                />
            View>
        );
    }

More Usage:

GitHubPopular

API
react-native-easy-toast, 一款简单易用的 Toast 组件,支持 Android&iOS._第1张图片

Contribution

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.

你可能感兴趣的:(Toast,ReactNative)