I have a table where each row might be clicked and then it should change a color and later on be used to filter out selected items. In each row I have an item:
interface Item{
id:string;
name:string;
price:number;
}
I am wondering what is a better approach regarding EntityStateAdapter:
- add
isSelectedproperty toItemand later on updating this part of state?
OR
- extend Adapter state and store selected items in array.
export const adapter: EntityAdapter<Item> = createEntityAdapter<Item>();
export const initialState: EntityState<Item> = adapter.getInitialState({
selectedItems:Array<string>
})
IMO 1st approach is better. It is easier to just add property to Item, because later on I can easily reflect the state in table for each row just by item.isSelected. I would like to hear about your experience.
I prefer to use
selectedItems, reasons: