useNotification
useNotification is a custom hook to handle toast like adding/removing of Alert and Snackbar.
import { useNotification, AlertAction } from '@wpmedia/arc-ui-notification'Return value
The useNotification hook returns:
notify
notify(message: string, options?: NotifyOptions): number| Props | Description |
|---|---|
actions(optional) | undefined | Element | [Element, Element]Actions are passed through to the underlying Alert type. The value(s) of this prop should be
|
duration(optional) | 3000 | 4000 | 5000 | 6000 | 7000 | 8000 | 9000 | 10000 = 3000Optional from 3-10s. If type is |
status(optional) | undefined | "warning" | "publish" | "success" | "base" | "info" | "error" = baseStatus reflects the color of the alert |
type(optional) | "alert" | "snack" = snackVariant of the alert: Alert or Snackbar |
close
close(alertId: number): voidThe alert id is returned from the notify method.
Usage
Alert
Snackbar
AlertAction
AlertActions are a small extension to the Button component for use in the actions array of an Alert or a Snackbar. By default, clicking on an AlertAction closes the parent Alert or Snackbar.
Alerts take either one or two AlertActions, while Snackbars take either zero or one.
An AlertAction supports all the same props as a Button, with the addition of preventClose, used to indicate that the parent Alert or Snackbar should not close when the action is taken. See above examples.