GithubHelp home page GithubHelp logo

saiicharan / react-native-fast-toast Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arnnis/react-native-toast-notifications

0.0 1.0 0.0 262 KB

A Toast component for react-native, supports Android, IOS, Web, Windows

TypeScript 98.65% JavaScript 1.35%

react-native-fast-toast's Introduction

react-native-fast-toast

A Toast component for react-native, supports Android, IOS, Web, Windows

Features

  • Normal, Success, Danger and Warning toasts
  • Customizable and Icon support
  • Smooth animation
  • Fully typed with TypeScript

Demo

Install

Open a Terminal in the project root and run:

yarn add react-native-fast-toast

Basic Example

import React, { useEffect, useRef } from "react";
import { View } from "react-native";
import Toast from "react-native-fast-toast";

export default function App() {
  const toast = useRef(null);

  useEffect(() => {
    toast.current.show("Task finished successfully");
  }, []);

  return (
    <>
      <RestOfYourApp />
      <Toast ref={toast} />
    </>
  );

Global Example

If you want to have one Toast and use it everywhere on your app. do this in root component of your app (index.js or App.js)

import React, { useEffect, useRef } from "react";
import { View } from "react-native";
import Toast from "react-native-fast-toast";

export default function App() {
  const toast = useRef(null);

  useEffect(() => {
    // Here
    global['toast'] = toast.current

  }, []);

  return (
    <>
      <RestOfYourApp />
      <Toast ref={toast} />
    </>
  );

now you can call toast.show() everywhere on app. like alert.

Check index.d.ts in example app for typescript.

Type Example

toast.current.show("Task finished successfully", { type: "success" });

Icon Example

toast.current.show("Task finished successfully", { icon: <Icon /> });

or

<Toast
  ref={toast}
  icon={<Icon />}
  successIcon={<SuccessIcon />}
  dangerIcon={<DangerIcon />}
  warningIcon={<WarningIcon />}
/>
}

Customize

toast.current.show("Task finished successfully", {
  duration: 5000,
  style: { padding: 0 },
  textStyle: { fontSize: 20 },
});

You can customize default options in Toast component

<Toast ref={toast} duration={5000} textStyle={{ fontSize: 20 }} />

Contributing

Pull request are welcome.

While developing, you can run the example app to test your changes.

react-native-fast-toast's People

Contributors

arnnis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.