@amitsolanki1409/react-native-toast-message
Version:
A customizable and lightweight toast component for React Native.
20 lines (19 loc) • 603 B
JavaScript
import React, { useState } from "react";
import { View } from "react-native";
import ToastService from "./ToastService";
class Toast {
static show(options) {
this.setToast(options);
}
static hide() {
this.setToast(null);
}
static ToastContainer() {
const [toast, setToast] = useState(null);
Toast.setToast = setToast;
return (<View style={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }}>
{toast && <ToastService {...toast} onClose={() => setToast(null)}/>}
</View>);
}
}
export default Toast;