gor181 / react-notification-system-redux

Redux wrapper for react-notification-system
MIT License
324 stars 59 forks source link

Using Date.now() inside a reducer #2

Closed jrrmt closed 8 years ago

jrrmt commented 8 years ago

I noticed Date.now() is being used inside the reducer to generate a fallback action uid.

This makes the reducer function impure by depending on external state, which should not be the case when working with redux. This will cause all sorts of trouble with redux-devtools or any kind of time travelling debugger.

I'd suggesting moving the Date.now() uid fallback logic to the action generators and depend exclusively on action data inside the reducer.

For anyone having trouble with this: a simple workaround is to always pass a uid parameter when showing a notification.

gor181 commented 8 years ago

Hey @phoenity ,

You are absolutely right, overlooked that part. Moved the fallback to actions.

Thank you for reporting, its in 1.0.2

Cheerio!

jrrmt commented 8 years ago

You're welcome! Thanks for the swift fix :)