- Using NPM
npm install @volkenomakers/toast - or:
- Using Yarn
yarn add @volkenomakers/toast
import React from "react";
import { View } from "react-native";
import { Button } from "react-native-elements";
import { useToast, ToastProvider } from "@volkenomakers/toast";
const ToastMessages = () => {
const toast = useToast();
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Button
title="Show Success message"
onPress={() => toast.success("this is an example of success message")}
/>
<Button
title="Show error message"
onPress={() => toast.error("this is an example of error message")}
containerStyle={{ marginVertical: 20 }}
/>
<Button
title="Show warning message"
onPress={() => toast.warning("this is an example of warning message")}
containerStyle={{ marginVertical: 20 }}
/>
<Button
title="Show message with 10 seconds of duration"
onPress={() =>
toast.success(
"this is an example of success message with 10s of duration",
10 * 1000
)
}
containerStyle={{ marginVertical: 20 }}
/>
</View>
);
};
const ToastApp = () => {
return (
<ToastProvider>
<ToastMessages />
</ToastProvider>
);
};
export default ToastApp;API
success(message: string, durationMs?: number)error(message: string, durationMs?: number)warning(message: string, durationMs?: number)
ISC Licensed
