ToastContext
Provides a global toast notification system for displaying temporary messages to users.Setup
Wrap your app with theToastProvider to enable toast notifications throughout your application:
useToast Hook
TheuseToast hook provides access to the toast functionality.
Return Value
Function to display a toast notification.Parameters:
message(string, required): The text to display in the toasttype(ToastType, optional): The type of toast. Defaults to"info". Options:"success"- Green background for success messages"error"- Red background for error messages"warning"- Yellow background for warning messages"info"- Blue background for informational messages
TypeScript Interfaces
Usage Examples
Form Validation Example
API Request Example
Toast Behavior
- Toasts appear at the top of the screen (60px from top)
- Automatically dismiss after 3.5 seconds
- Can be manually dismissed by tapping
- Multiple toasts stack vertically
- Smooth slide and fade animations
- High z-index ensures visibility above other content
Error Handling
TheuseToast hook will throw an error if used outside of a ToastProvider:
ToastProvider before using the useToast hook.