@sibilance.is/client v0.1.0-alpha.4
@sibilance.is/client / react / useToast
Function: useToast()
ts
function useToast(): {
showToast: (msg, toastType) => void;
hideToast: () => void;
toastProps: {
message: string;
type: ToastType;
isOpen: boolean;
onClose: () => void;
};
};Defined in: CmdPr/sibilance/client/src/components/SurveyToast.tsx:189
Hook for managing toast state
Returns
ts
{
showToast: (msg, toastType) => void;
hideToast: () => void;
toastProps: {
message: string;
type: ToastType;
isOpen: boolean;
onClose: () => void;
};
}| Name | Type | Default value | Defined in |
|---|---|---|---|
showToast() | (msg, toastType) => void | - | CmdPr/sibilance/client/src/components/SurveyToast.tsx:205 |
hideToast() | () => void | - | CmdPr/sibilance/client/src/components/SurveyToast.tsx:206 |
toastProps | { message: string; type: ToastType; isOpen: boolean; onClose: () => void; } | - | CmdPr/sibilance/client/src/components/SurveyToast.tsx:207 |
toastProps.message | string | - | CmdPr/sibilance/client/src/components/SurveyToast.tsx:208 |
toastProps.type | ToastType | - | CmdPr/sibilance/client/src/components/SurveyToast.tsx:209 |
toastProps.isOpen | boolean | - | CmdPr/sibilance/client/src/components/SurveyToast.tsx:210 |
toastProps.onClose() | () => void | hideToast | CmdPr/sibilance/client/src/components/SurveyToast.tsx:211 |
Example
tsx
const { showToast, toastProps } = useToast();
// Show toast
showToast('Survey completed!', 'success');
// Render toast
<SurveyToast {...toastProps} />