1.0.2 • Published 4 years ago

@fiovex/react-native-dropdown-alert v1.0.2

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

react-native-dropdown-alert

Platform npm version License

screenshot screenshot screenshot screenshot

Table of contents

  1. Installation
  2. Demo
  3. Usage
  4. Props

A simple alert to notify users about new chat messages, something went wrong or everything is ok. It can be closed by tap, cancel button, automatically with closeInterval, pan responder up gesture or programmatically (this.dropDownAlertRef.closeAction()).

Installation

npm i @fiovex/react-native-dropdown-alert --save

Demo

screenshot

Usage

import DropdownAlert from "@fiovex/react-native-dropdown-alert";
export default class App extends Component {
  componentDidMount() {
    this._fetchData();
  }
  _fetchData = async () => {
    try {
      await fetch("https://mywebsite.com/endpoint/");
      // alertWithType parameters: type, title, message, payload, interval.
      // There are 4 pre-defined types: info, warn, success, error.
      // payload object with source property overrides image source prop. (optional)
      // interval overrides closeInterval prop. (optional)
      this.dropDownAlertRef.alertWithType(
        "success",
        "Success",
        "Fetch data is complete."
      );
    } catch (error) {
      this.dropDownAlertRef.alertWithType("error", "Error", error.message);
    }
  };
  render() {
    // Make sure DropdownAlert is the last component in the document tree.
    return (
      <View>
        <DropdownAlert ref={(ref) => (this.dropDownAlertRef = ref)} />
      </View>
    );
  }
}

Inspired by: RKDropdownAlert