recently encountered a confusion as follows:
suppose I get a list of original items by request, and I store it in store
state = {
products:[...]
}
in a component, users can hide items they don"t care about (ps: is not deleted, similar to adding a show:false attribute). I thought of several ways myself:
1. Add a show attribute to each item in products directly.
II. Create another backup of products in store productsCopy
, and then add the show attribute.
3. Save a copy of the products to the private state of this component.
the problem is:
1. In method 1, when more and more fields are added, there will be a lot of initialization work to be done after requesting the products interface.
2. For the state that other components don"t care about, I don"t think it"s a good choice to put it in redux store, and I need to write action, reducer, constant, write all kinds of import, etc., a lot of code.
3. Method 3 needs to listen for changes in products in componentWillReceiveProps, and then transfer Synchronize to private state. It feels a bit troublesome, and it"s not easy to tell the difference between props.products changes and other props changes.
how do you usually deal with it? Is there a better solution?