mirror of
https://github.com/zhigang1992/firecms.git
synced 2026-06-14 09:38:59 +08:00
1.2 KiB
1.2 KiB
id, title, sidebar_label
| id | title | sidebar_label |
|---|---|---|
| use_snackbar_controller | useSnackbarController | useSnackbarController |
:::note
Please note that in order to use these hooks you must be in
a component (you can't use them directly from a callback function).
Anyhow, callbacks usually include a FireCMSContext, which includes all
the controllers.
:::
Use this hook to get a snackbar controller to display snackbars, with a message, a type and an optional title.
The props provided by this context are:
isOpenIs there currently an open snackbarclose()Close the currently open snackbaropen ({ type: "success" | "info" | "warning" | "error"; title?: string; message: string; })Display a new snackbar. You need to specify the type and message. You can optionally specify a title
Example:
import React from "react";
import { useSnackbarController } from "@camberi/firecms";
export function ExampleCMSView() {
const snackbarController = useSnackbarController();
return (
<Button
onClick={() => snackbarController.open({
type: "success",
title: "Hey!",
message: "Test snackbar"
})}>
Click me
</Button>
);
}