@silicon.js/toasts
v1.0.2
Published
A customizable toast notification package for React Native using React Context and react-native-paper.
Maintainers
Readme
Toast Package
A customizable toast notification package for React Native using React Context and react-native-paper.
Usage Example
Wrap your root with ToastWrapper:
import React from 'react';
import { ToastWrapper } from '@your-org/toast';
export default function App() {
return (
<ToastWrapper>
{/* other providers */}
{/* app screens here */}
</ToastWrapper>
);
}Render toast component in your root once:
import { Toast } from '@your-org/toast';
function Root() {
return (
<>
<AppNavigation />
<Toast />
</>
);
}Trigger toast anywhere:
import { useToast } from '@your-org/toast';
const DemoScreen = () => {
const { showSuccess, showError } = useToast();
return <Button onPress={() => showSuccess('Saved Successfully!')} title="Show Toast" />;
};Toast Methods
| Method | Description | | ----------- | -------------------- | | showSuccess | green success toast | | showError | red error toast | | showInfo | grey info toast | | showWarning | yellow warning toast | | hide | hide toast manually |
