tomchentw/react-toastr

Allow to set own messages comparator

jeron-diovis opened this issue · 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?

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!

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

@tomchentw I will create a pull request ASAP.