fkhadra / react-toastify

React notification made easy 🚀 !
https://fkhadra.github.io/react-toastify/introduction
MIT License
12.27k stars 673 forks source link

Add a data attribute to ToastContainer #1106

Open Miladxsar23 opened 1 month ago

Miladxsar23 commented 1 month ago

Feature-request: Add a data attribute to ToastContainer

Description:

As part of improving the testability of react-toastify, I propose adding a data attribute to the ToastContainer component. This would allow us to easily target specific toasts in our E2E tests, making them more precise and efficient.

Benefits:

Implementation:

There are two main approaches to implementing this feature:

  1. Add a new prop to ToastContainer: This is the simplest approach. We can add a new prop called dataAttribute to ToastContainer that allows users to specify their own data attribute for toasts.

  2. Use the useToast hook: The useToast hook in react-toastify allows us to create toasts programmatically. We can modify this hook to add a dataAttribute prop that allows users to specify the data attribute for the toast they are creating.

Considerations:

Call to action:

I would love to discuss this proposal further with the react-toastify team and get your feedback on the best way to implement it. I am also happy to contribute code if needed.