Skip to content

@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;
  };
}
NameTypeDefault valueDefined 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.messagestring-CmdPr/sibilance/client/src/components/SurveyToast.tsx:208
toastProps.typeToastType-CmdPr/sibilance/client/src/components/SurveyToast.tsx:209
toastProps.isOpenboolean-CmdPr/sibilance/client/src/components/SurveyToast.tsx:210
toastProps.onClose()() => voidhideToastCmdPr/sibilance/client/src/components/SurveyToast.tsx:211

Example

tsx
const { showToast, toastProps } = useToast();

// Show toast
showToast('Survey completed!', 'success');

// Render toast
<SurveyToast {...toastProps} />