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

Allow to set own messages comparator

Open jeron-diovis opened this issue 9 years ago • 3 comments

I pass a rendered React elements as messages. As they are objects, they are never equal, so preventDuplicates feature does not work for me. So, how about introducing a new prop, which will accept a comparator function? It will allow for everyone to implement any specific logic he needs, and will require a very few changes.

Also: you import entire Lodash and only use _.includes. Lodash is huge, it's a horrible dependency. You can instead do import includes from "lodash/includes", it will save a LOT of bytes. Or just check messageList.indexOf(message) – actually, this is the only thing needed here, isn't it?

jeron-diovis avatar Jul 14 '16 16:07 jeron-diovis

You make some good points. I agree that Lodash can be replaced with a lighter implementation. I would strongly recommend you to fork toastr and create a pull request incorporating these changes. Please advise. Cheers!

RangarajKaushikSundar avatar Jul 19 '16 18:07 RangarajKaushikSundar

The lodash issue can be fixed by using babel-plugin-lodash. Does anyone want to create a PR to fix this?

tomchentw avatar Aug 01 '16 01:08 tomchentw

@tomchentw I will create a pull request ASAP.

RangarajKaushikSundar avatar Aug 01 '16 19:08 RangarajKaushikSundar