timolins / react-hot-toast

Smoking Hot React Notifications 🔥
https://react-hot-toast.com
MIT License
9.84k stars 331 forks source link

Order of properties can break certain functionalities. #222

Closed vikramnayyarcs closed 2 years ago

vikramnayyarcs commented 2 years ago

Take the following 2 lines:

toast.error('Dashboard name cannot be empty.', {id: 'DashboardNameNotEmpty'}, {style: {backgroundColor: '#FFFFFF33', color: 'white'}} );
toast.error('Dashboard name cannot be empty.', {style: {backgroundColor: '#FFFFFF33', color: 'white'}}, {id: 'DashboardNameNotEmpty'} );

The 1st line will only re-render the toast when the toast changes. The 2nd line will re-render multiple times (not appropriate for my useCase) but on the other hand, it retains the styles.

Ideally both the ID functionality and the styles should be retained (not break based on their order).

timolins commented 2 years ago

Hi! The toast function takes only two arguments: the message & the options object. In you example only the first object is respected. You can combine them into one:

toast.error("Dashboard name cannot be empty.", {
  id: "DashboardNameNotEmpty",
  style: { backgroundColor: "#FFFFFF33", color: "white" },
});