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

Allow 0 as a snackbar key identifier #187

Merged
merged 2 commits into from
Oct 28, 2019

Conversation

JimmyMultani
Copy link
Contributor

At the moment, setting the key option to 0 will not respect it, and generate a random id based on new Date().getTime() + Math.random().

This fix will check if the value of key is undefined before defaulting to auto-generating the id.

A specific use case for this would be when receiving payloads from an external source (like a subscription service), where the id could possibly start at 0.

At the moment, setting the `key` option to `0` will not respect it, and generate a random `id` based on `new Date().getTime() + Math.random()`.

This fix will check if the value of `key` is `undefined` before defaulting to auto-generating the `id`.

A specific use case for this would be when receiving payloads from an external source (like a subscription service), where the `id` could possibly start at `0`.
@iamhosseindhv
Copy link
Owner

What if key is null or ''?
I'd prefer explicit check against 0.

based off feedback, would prefer to check if 0 directly, than implicit !== 'undefined'
@JimmyMultani
Copy link
Contributor Author

I've changed it based off your feedback, @iamhosseindhv.

@iamhosseindhv iamhosseindhv merged commit 4388455 into iamhosseindhv:master Oct 28, 2019
@iamhosseindhv
Copy link
Owner

Thanks @JimmyMultani 💙

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

Successfully merging this pull request may close these issues.

2 participants