Notistack: useSnackbar: Cannot read property 'handleEnqueueSnackbar' of undefined

Created on 15 Jun 2019  路  2Comments  路  Source: iamhosseindhv/notistack

Expected Behavior


Should load without error when consuming via hook.
const { enqueueSnackbar, closeSnackbar } = useSnackbar();

Current Behavior


Throws an error Cannot read property 'handleEnqueueSnackbar' of undefined.

Steps to Reproduce


Link: https://codesandbox.io/s/strange-bird-jclt4

  1. import useSnackbar
  2. add const { enqueueSnackbar, closeSnackbar } = useSnackbar();
    Page should now fail and show an error.

Most helpful comment

You forgot to wrap your app inside a SnackbarProvider. See basic usage for more info.

working example:
https://codesandbox.io/s/gifted-https-ply3y

All 2 comments

You forgot to wrap your app inside a SnackbarProvider. See basic usage for more info.

working example:
https://codesandbox.io/s/gifted-https-ply3y

Doh!!!

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VincentLanglet picture VincentLanglet  路  3Comments

RastislavMirek picture RastislavMirek  路  8Comments

james-cordeiro picture james-cordeiro  路  6Comments

nebojsanb picture nebojsanb  路  3Comments

ksavery picture ksavery  路  3Comments