I'm writing my first Redux app. In my store, I have ~300-500 Island
objects that I retriev from an API and index by an id
string in an object (being treated like a map). When I'm editing one of these Island
s by setting editId
in the store, the buttons for the other Island
s need to be disabled. I can think of three ways I can do this.
- Have all of the components watch
editId
for changes and check theirIsland.id
against theeditId
(I'm guessing this is very slow) - Add a
disabled
prop to my island component, have the container that maps theIsland
s to components watch foreditId
, and calculatedisabled
for each island on render - Add a
disabled
field to theIsland
objects in the store and update each of these objects when my edit action
My hunch is option 2, as that would definitely be the cleanest approach.
This question is coming from a place of migrating from mobx (which had terrible performance) to redux, and hoping performance improves. If any of the three of these will have virtually the same performance, then I'll choose option 2. I just don't know if there's a redux pattern established that I should be using.