JSPM

use-snackbar

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q41518F
  • License MIT

Package Exports

  • use-snackbar

Readme

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