Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When does enqueueSnackbar return null? #217

Closed
Svish opened this issue Jan 23, 2020 · 1 comment
Closed

When does enqueueSnackbar return null? #217

Svish opened this issue Jan 23, 2020 · 1 comment

Comments

@Svish
Copy link

Svish commented Jan 23, 2020

I'm creating a wrapper for useSnackbar with some defaults and additions in our project, and since we're using Typescript I want the typings to be correct. And in the notistack typings there's a thing I don't quite understand:

The enqueueSnackbar function is typed to return OptionsObject['key'] | null, while closeSnackbar can only accept OptionsObject['key'].

In what sort of cases does enqueueSnackbar return null? 🤔

export interface WithSnackbarProps {
    enqueueSnackbar: (message: SnackbarMessage, options?: OptionsObject) => OptionsObject['key'] | null;
    closeSnackbar: (key?: OptionsObject['key']) => void;
}

https://github.com/iamhosseindhv/notistack/blob/master/src/index.d.ts#L35-L38

I've tried to figure it out from the documentation and looking in the source, but couldn't really find it... 😕

@iamhosseindhv
Copy link
Owner

iamhosseindhv commented Jan 23, 2020

This is incorrect type in index.d.ts.
We used to return null when preventDuplicate props was set to true.

As mentioned here, as of #189 enqueueSnackbar no longer return null.

Fix will be published in v0.9.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants