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

Add container id to onChange event #403

Closed
orest22 opened this issue Nov 18, 2019 · 2 comments
Closed

Add container id to onChange event #403

orest22 opened this issue Nov 18, 2019 · 2 comments
Assignees

Comments

@orest22
Copy link

orest22 commented Nov 18, 2019

Do you want to request a feature or report a bug?

Feature

What is the current behavior?

I am trying to show/hide something based on amount of toasts in a certain container
I am using toast.onChange to get a number of items inside the container. But event fires for every container.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your CodeSandbox (https://codesandbox.io/s/new) example below:

N/A

What is the expected behavior?

It would be great to have a container id for ACTION.ON_CHANGE event.

Or allow each container to have it own onChange callback

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

16.9

@fkhadra fkhadra self-assigned this Nov 18, 2019
@fkhadra
Copy link
Owner

fkhadra commented Nov 18, 2019

Indeed good idea ! I'm thinking about something like that

interface OnChangeProps {
  count: number;
  containerId: string | number | nulll
}

toast.onChange({ count, containerId }: onChangeProps) => { //do whatever you want })

Of course this will introduce a breaking change.

Or if we want to keep it BC the signature must be

toast.onChange((count, containerId) => { })

What do you think @orest22 ?

@orest22
Copy link
Author

orest22 commented Nov 19, 2019

@fkhadra Looks good to me! Thanks for so quick reply.
Should’ve just made PR.

fkhadra added a commit that referenced this issue Dec 30, 2019
The containerId is available as the second argument to preserve the backward compatibility
@fkhadra fkhadra closed this as completed Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants