react-native-animated-custom-toast
v1.0.0
Published
A fully customized and easy to use toast for react native
Downloads
1
Readme
Custom React Native Toast
This is a toast package for reac native. it is easy to implement and develpoers can customized it accordingly.
Installation
$ npm i react-native-animated-custom-toast
Usage
- Import react-native-animated-custom-toast:
import Toast from "react-native-animated-custom-toast";
- Create ref for toast
const toastRef = useRef(null);
- Create a component in return part and pass required props with toast ref which is mandatory
<Toast
toastColor={"red"}
toastTextColor={"white"}
toastMessage={"Hello from toast"}
ref={toastRef}
iconTintColor:"white"
/>
- Trigger toast whenever required with the help of toast ref
toastRef.current.showToast();
Complete Example
import React, { useRef } from "react";
import { Button, View } from "react-native";
import Toast from "react-native-animated-custom-toast";
const App = () => {
const toastRef = useRef(null);
return (
<View style={{ flex: 1 }}>
<Button title="Show Toast" onPress={()=>{toastRef.current.showToast();}} />
<Toast
toastColor={"red"}
toastTextColor={"white"}
toastMessage={"Hello from toast"}
ref={toastRef}
iconTintColor:"white"
/>
</View>
);
}
export default App;