artsy/positron — pull request #41 by craigspaeth (2014-11-04 19:41:54+00:00)
Title: @dzucconi: Artworks don't refetch when the list of sections are re-rendered

When adding or removing sections the artwork section component would re-mount causing the artworks to unnecessarily re-fetch from the server. This caches the fetched artworks on the model by adding a `getOrFetchIds` method.

To go on a tangent:

I struggled a bit trying to figure out how React might deal with this—[this thread](http://stackoverflow.com/questions/21709905/can-i-avoid-forceupdate-when-using-react-with-backbone?rq=1) was interesting. When working with Backbone models & React it's kind of hard to determine where your "source of truth" is. On one hand Backbone uses models/collections as a source of truth (at-least for domain data), on the other hand React wants the components "state" to be the source of truth for view state and stateful domain data. It seems like using `@props.model.on 'change', @forceUpdate` is considered an anti-pattern—However, the other option of serializing models into raw data, passing around a bunch of `onChangeX` callbacks, and deserializing state back into the models for persistence seems like a lot of ugly ceremony.

So I'm still not sure what the "right" way to do this is. For the time being it seems nicest to use models/collections + events + `forceUpdate` for stateful domain data and `component.state` for view state like `editingMode: true`. ¯\_(ツ)_/¯