How to use the notistack.useSnackbar function in notistack

To help you get started, we’ve selected a few notistack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xyfir / illuminsight / components / Edit.tsx View on Github external
export function Edit(): JSX.Element | null {
  const [language, setLanguage] = React.useState<
    Illuminsight.Pub['languages'][0]
  >('');
  const { enqueueSnackbar } = useSnackbar();
  const [cover, setCover] = React.useState();
  const [tags, setTags] = React.useState([]);
  const [pub, setPub] = React.useState(null);
  const [tag, setTag] = React.useState('');
  const history = useHistory();
  const classes = useStyles();
  const match = useRouteMatch();

  function onChange(prop: keyof Illuminsight.Pub, value: any): void {
    if (pub) setPub({ ...pub, [prop]: value });
  }

  function onResetBookmark(): void {
    onChange('bookmark', {
      element: 0,
      section: 0,
github viclafouch / PE-Center / src / js / containers / popup / Settings.jsx View on Github external
function Settings() {
  const { t } = useTranslation()
  const [{ productsSelected, lang, maxThreadsPerProduct, openLinkIn, displayNotifications }, dispatch] = useSettings()
  const [{ startPage }, defaultDispatch] = useContext(DefaultContext)
  const [theme, setTheme] = useTheme()
  const [products, setProducts] = useState([])
  const { enqueueSnackbar } = useSnackbar()

  useEffect(() => {
    ;(async () => {
      const localStorage = await getBrowserStorage('local')
      setProducts(localStorage.products)
      try {
        const response = await getAllProducts()
        const result = response.result.map(e => ({
          ...e,
          icon: `${e.name
            .toLowerCase()
            .split(' ')
            .join('-')}-64.png`
        }))
        if (JSON.stringify(localStorage.products) === JSON.stringify(result)) return
        setBrowserStorage('local', { products: result })
github viclafouch / PE-Center / src / js / containers / popup / SearchCards.jsx View on Github external
export function SearchCards() {
  const { t } = useTranslation()
  const { enqueueSnackbar } = useSnackbar()
  const [isEndOfList, setIsEndOfList] = useState(true)
  const [isError, setIsError] = useState(false)
  const [{ cards, isSearching }, dispatch] = useContext(DefaultContext)
  const [{ page, value }, { setPage }] = useSearchParams()
  const [{ productsSelected, lang }] = useSettings()
  const currentLang = useRef(lang)
  const productsVisible = useRef(productsSelected.filter(e => e.visible).length)
  const isSubscribed = useRef(false)

  useEffect(() => {
    const controller = new AbortController()
    if (!productsSelected.length) {
      dispatch({ type: REMOVE_CARDS })
      dispatch({ type: SET_SEARCHING_STATUS, isSearching: false })
      return
    }
github justinmahar / easyjre / src / components / CopyPasteModulesContainer.tsx View on Github external
export default function CopyPasteModulesContainer(
  props: ICopyPasteModulesContainerProps
) {
  const { enqueueSnackbar } = useSnackbar();
  const [pastedModulesList, setPastedModulesList] = React.useState("");
  const [clipboardErrorOccurred, setClipboardErrorOccurred] = React.useState(
    false
  );

  const handleClickCopyListModulesCommand = () => {
    let commandTextarea: any = document.getElementById("list-modules-command");
    commandTextarea.select();
    document.execCommand("copy");
    enqueueSnackbar("✔️ Copied!");
  };

  const navigatorClipboardSupported =
    !clipboardErrorOccurred && !!navigator.clipboard && !!navigator.clipboard.readText;

  const parsePastedList = (text: string) => {
github magma / magma / symphony / app / fbcnms-packages / fbcnms-ui / hooks / useSnackbar.js View on Github external
export default function useSnackbar(
  message: string,
  config: AllowedConfig,
  show: boolean,
  dismissPrevious?: boolean,
) {
  const {enqueueSnackbar, closeSnackbar} = useNotistackSnackbar();
  const stringConfig = JSON.stringify(config);
  const [snackbarKey, setSnackbarKey] = useState(null);
  useEffect(() => {
    if (show) {
      const config: AllowedConfig = JSON.parse(stringConfig);
      const k = enqueueSnackbar(message, {
        children: key => (
          
        ),
        ...config,
      });
      if (dismissPrevious) {
github mimecuvalo / helloworld / client / app / App.js View on Github external
function CloseButton(snackKey) {
  const intl = useIntl();
  const snackbar = useSnackbar();
  const closeAriaLabel = intl.formatMessage(messages.close);

  return (
     snackbar.closeSnackbar(snackKey)}
      className="App-snackbar-icon"
      color="inherit"
      aria-label={closeAriaLabel}
    >
      
    
  );
}
github magma / magma / nms / app / fbcnms-packages / fbcnms-alarms / hooks / useSnackbar.js View on Github external
export function useEnqueueSnackbar() {
  const {enqueueSnackbar} = useNotistackSnackbar();
  return useCallback(
    (message: string, config: Object) =>
      enqueueSnackbar(message, {
        children: key => (
          
        ),
        ...config,
      }),
    [enqueueSnackbar],
  );
}
github justinmahar / easyjre / src / components / CreateJREContainer.tsx View on Github external
export default function CreateJREContainer(props: ICreateJREContainerProps) {
  const { enqueueSnackbar } = useSnackbar();

  let includedModulesString: string = props.includedJDKModules.join(",");
  let optionAdditionalModules: string = props.manuallySpecifiedModules.trim();

  let moduleString: string = "";

  if (includedModulesString !== "" || optionAdditionalModules !== "") {
    moduleString = " --add-modules ";
    if (includedModulesString !== "") {
      moduleString += includedModulesString;
    }
    if (includedModulesString !== "" && optionAdditionalModules !== "") {
      moduleString += ",";
    }
    if (optionAdditionalModules !== "") {
      moduleString += optionAdditionalModules;
github mimecuvalo / helloworld / packages / hello-world-editor / ui / toolbars / Buttons.js View on Github external
export function ImageButton(props) {
  const intl = useIntl();
  const snackbar = useSnackbar();
  const styles = useStyles();

  const handleMouseDown = evt => evt.preventDefault();

  const handleClick = evt => {
    evt.preventDefault();

    document.forms[IMAGE_FORM_NAME].elements[IMAGE_INPUT_NAME].click();
  };

  const handleFileChange = async (evt, files) => {
    const { editorState, isError } = await uploadFiles(props.onMediaUpload, props.getEditorState(), evt.target.files);

    document.forms[IMAGE_FORM_NAME].elements[IMAGE_INPUT_NAME].value = null;

    if (isError) {
github mimecuvalo / helloworld / packages / hello-world-editor / ui / HiddenSnackbarShim.js View on Github external
export default function HiddenSnackbarShim({ message, variant }) {
  const intl = useIntl();
  const snackbar = useSnackbar();

  useEffect(() => {
    snackbar.enqueueSnackbar(intl.formatMessage(message), { variant });
  });

  return null;
}

notistack

Highly customizable notification snackbars (toasts) that can be stacked on top of each other

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis