react-native-dj-toastwithicon

daojia react-native-dj-toastwithicon

Usage no npm install needed!

<script type="module">
  import reactNativeDjToastwithicon from 'https://cdn.skypack.dev/react-native-dj-toastwithicon';
</script>

README

Toast

accordion

Install

npm i --save react-native-dj-toastwithicon

Usage

Using in your app will usually look like this:

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableHighlight,
} from 'react-native';

import Toast from 'react-native-dj-toast';


export default class NPMTest extends Component {

    render() {
      return (
        <View style={{marginTop:20}}>
          <TouchableHighlight onPress={()=>this.refs.toast.show('This is a toast!')}>
            <Text>click me</Text>
          </TouchableHighlight>
          <Toast ref="toast" />
        </View>
      );
    }
}

AppRegistry.registerComponent('xxx', () => NPMTest);

Props

The following props can be used to modify the style and/or behaviour:

Prop Type Opt/Required Default Note
icons array Option [] 需要显示的icon,可以传多个icon,形式如 [require('image!success_black'),require('image!error_black')]

Methods

The following methods can be used to open and close the Dialog:

Method Parameters Note
show message:需要显示的信息,time:toast显示的时长,默认为2000ms,iconIdx:需要显示的icon在icons数组中的位置 iconIdx可不传,默认为0