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

preventDuplicates not working either as a prop on ReduxToastr or when using the emitter #261

Open
ahayes91 opened this issue Jun 8, 2020 · 4 comments
Labels

Comments

@ahayes91
Copy link

ahayes91 commented Jun 8, 2020

We have the ReduxToastr component at the root of our app with preventDuplicates props set to true:

<ReduxToastr
    timeOut={0}
    position="top-right"
    transitionIn="fadeIn"
    transitionOut="fadeOut"
    preventDuplicates={true}
/>

We fire toastr add action (by using a @ReduxToastr/toastr/ADD type Redux action) with the following payload in the app (I've made some changes to demonstrate that the message and title and type are definitely the same on all the toastrs we create):

      id: getRandomId(), // a function to create a random id, we use this because react-redux-toastr will keep track of the id internally for closing via CustomToastrButton which we need for aria-labels and closing modals with the ESC button
      message: 'Aislinn is testing',
      options: {
        timeOut: 5000,
        icon: <NotificationSuccessLge />,
        removeOnHover: false,
        showCloseButton: false,
        component: <CustomToastrButton toastMsgId="toast.closeSuccessToast" />,
        preventDuplicates: true,
      },
      position: 'top-right',
      title: 'Aislinn is still testing',
      type: 'success',

preventDuplicates doesn't work for us with these settings. I had a look at the source code for preventDuplication https://github.com/diegoddox/react-redux-toastr/search?q=prevent+duplicates&unscoped_q=prevent+duplicates and I figured having the same message/title/and type should be enough for this. Is there something else I'm missing?

The version of react-redux-toastr we're using is "5.0.7" - a little bit out of date but preventDuplicates should work on that.

@ahayes91
Copy link
Author

@diegoddox anything obvious you can spot that we're doing wrong here by any chance?

@diegoddox
Copy link
Owner

@ahayes91 you're right, by providing the same title, message and type should do the work, will take a look asap.

@diegoddox diegoddox added the bug label Jun 10, 2020
@diegoddox
Copy link
Owner

Help wanted, not sure when I will be able to look at this issue.

@ThevinMalaka
Copy link

ThevinMalaka commented Mar 12, 2023

This method helps to me prevent the duplicates toastrs in react-redux-toastr

Saga file


toastr.warning("Loading", "Please wait while we upload the file.");

toastr.clean(); // clean the previous toastr

toastr.success("Success", "Successfully uploaded the file.");

setTimeout(() => {
        toastr.clean(); //  clean the toastr after 3 seconds
}, 3000);

index.js


<ReduxToastr
      timeOut={2000}
      newestOnTop={false}
      preventDuplicates={true}
      position="top-right"
      getState={(state) => state.toastr} // This is the default
      transitionIn="fadeIn"
      transitionOut="fadeOut"
      progressBar
      closeOnToastrClick
/>

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

No branches or pull requests

3 participants