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 = 3000 Optional from 3-10s. If type is |
status (optional) | undefined | "warning" | "publish" | "success" | "base" | "info" | "error" = base Status reflects the color of the alert |
type (optional) | "alert" | "snack" = snack Variant of the alert: Alert or Snackbar |
close
close(alertId: number): void
The alert id is returned from the notify
method.
Usage
Alert
Snackbar
AlertAction
AlertAction
s 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
.
Alert
s take either one or two AlertAction
s, while Snackbar
s 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.