jvalen / pixel-art-react

Pixel art animation and drawing web app powered by React
https://www.pixelartcss.com/
MIT License
5.43k stars 306 forks source link

Why SimpleNotification component connected? #5

Closed pke closed 8 years ago

pke commented 8 years ago

I wonder why the SimpleNotification component is connected? It does neither use state nor actions and could therefor be a "dumb" component. Or am I missing something?

jvalen commented 8 years ago

Hi @pke! Thanks for asking!

SimpleNotification works in the following way:

  1. A component send an action SEND_NOTIFICATION with the appropriate message.
  2. The store creates a new state with the message.
  3. The main app component send the notification in this state to the SimpleNotification component.
  4. SimpleNotification render the messages and remove then sending an action SEND_NOTIFICATION with an empty string. Creating a new state with no notification messages.

I think because it sends an action is not a "dumb" component. I should remove mapStateToProps though because it doesn't use it.

Thanks!