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

Passing null message with options will not make use of options

Open JoshMcCullough opened this issue 6 years ago • 2 comments
trafficstars

https://github.com/diegoddox/react-redux-toastr/blob/fc90e35c421b05cf782c2b5091c16a345a57541b/src/utils.js#L69

This line results in incorrect results. When trying to pass a React component as part of the options parameter like so:

toastr.error("Error", null, { component: <strong>test</strong> })

This line of code will incorrectly select the second parameter (null) as the options parameter when it should have selected the third parameter. The fix is to pass an empty string as the second (message) parameter. However, my instinct is to pass null to indicate "no message". I suggest rewriting this line prefer the third parameter if there is one.

This affects all options. If you pass null as the second parameter, all options are effectively ignored.

JoshMcCullough avatar May 30 '19 11:05 JoshMcCullough

There is no need to pass the message if you're adding the options.

diegoddox avatar May 30 '19 12:05 diegoddox

According to the type definition, the 2nd parameter has to be a string. But the code allows it to be either the message or options. The type defs could be updated to allow for the 2nd parameter to be string | BasicToastrOptions.

But this is still a bug in cases where you would be passing three args, the third would never be chosen as the options arg if the 2nd was null.

JoshMcCullough avatar May 30 '19 12:05 JoshMcCullough

closing since it's too old

diegoddox avatar Mar 26 '23 19:03 diegoddox

Too old ... but is still relevant.

JoshMcCullough avatar Oct 06 '23 15:10 JoshMcCullough