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 onDismiss function option when a toast is created #39

Merged
merged 2 commits into from
Sep 23, 2019
Merged

Add onDismiss function option when a toast is created #39

merged 2 commits into from
Sep 23, 2019

Conversation

doncicuto
Copy link
Contributor

This component is quite useful, thanks a lot!

In my case, I wanted to perform some actions that should only be triggered once the toast was explicitely dismissed by clicking the close sign, so I've added the onDismiss support. onClose it is called either you click on the close sign or if the time passes and the toast is closed. With the onDismiss function, if you want to do specific things when the X is clicked, you now can do your stuff before the toast is closed.

@@ -16,6 +16,7 @@ function SemanticToast(props) {

const onDismiss = e => {
e.stopPropagation();
props.onDismiss();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please destructure onDismiss as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@ferrao
Copy link
Member

ferrao commented Sep 22, 2019

Don't understand the title of this PR, does not seem related to your description/code. Can you please clarify?

@doncicuto doncicuto changed the title Add onSupport function option when a toast is created Add onDismiss function option when a toast is created Sep 23, 2019
As requested, I've destructure onDismiss. I've chosen onDispel as a synonym for onDismiss inside semantic-toast.jsx to avoid repetition.
@ferrao ferrao merged commit a6badeb into academia-de-codigo:master Sep 23, 2019
@michael-harley
Copy link

@ferrao @doncicuto This change is not applied to npmjs, or is it just me?

I tried "react-semantic-toasts": "^0.6.4" for my package.json, but I only got this code for semantic-toast.jsx.
image

This is causing an error onDismiss is not a function.
image


I can easily solve this by changing my package.json into react-semantic-toasts: "https://github.com/academia-de-codigo/react-semantic-toasts", but this is not elegant and I want my package.json to be clean.

Can you help me with this, maybe I do something wrong.


I've tried:

  • Remove node_modules and yarn.lock
  • Re-run yarn command.

@michael-harley michael-harley mentioned this pull request Nov 5, 2019
@doncicuto
Copy link
Contributor Author

Hi @michael-harley,
I've created a small React app with create-react-app and I've tried to download react-semantic-toasts (0.6.4) from npmjs using yarn. onDismiss seems to work and I've uploaded the code to this repo: https://github.com/doncicuto/test-toast

Captura de pantalla de 2019-11-05 18-12-04

I've only set size to small as it complained about medium size not defined in current React Semantic version which has already been tackled in @jankaifer PRs.

I'm not sure what may be the cause for your issue but if I can help you let me know.

Cheers

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.

None yet

3 participants