use-snackbar
Installation
npm i use-snackbar
Examples
You can use the component without any props, which just will result in rendering an uncontrolled component
import { SnackbarProvider, useSnackbar } from "use-snackbar";
function App() {
return (
<SnackbarProvider>
<SomeComponent />
</SnackbarProvider>
);
}
function SomeComponent() {
const [open] = useSnackbar();
return (
<>
{/* other elements */}
<button onClick={() => open("triggered!")}>open</button>
</>
);
}
for the full documentation, check documentation section
Documentation
useSnackbar
const [open] = useSnackbar();
Type | Description | |
---|---|---|
open | (string) => void | Trigger notification show, takes one argument: the message to show |