react-redux-toastr icon indicating copy to clipboard operation
react-redux-toastr copied to clipboard

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

Open ahayes91 opened this issue 5 years ago • 4 comments
trafficstars

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 avatar Jun 08 '20 15:06 ahayes91

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

ahayes91 avatar Jun 10 '20 13:06 ahayes91

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

diegoddox avatar Jun 10 '20 16:06 diegoddox

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

diegoddox avatar Jun 14 '20 17:06 diegoddox

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
/>

ThevinMalaka avatar Mar 12 '23 12:03 ThevinMalaka