I have no problem with storing things like modal state, currently selected items, etc. in Redux, but I’m having trouble imagining a scenario where you would need to generate a random ID to associate a piece of state with an arbitrary component. Generally the Redux state tree would store the piece of UI state inside the “model” it is associated with.
As a super simple example, if you had a list of continents, and each continent could be expanded (to list every country inside of it) or collapsed, your Redux state might look like:
{
'continents': [
'Asia': {
'collapsed': false,
'countries': [
'Mongolia',
'Japan',
// ...
],
},
'North American': {
'collapsed': true,
'countries': [
'Canada',
'Mexico',
// ...
],
},
],
}
The 'collapsed' key is purely UI state for your collapsible component (i.e. you probably wouldn't sync it to a server), but it is keyed naturally in the Redux state along with the normal Redux data it's related to.In what case would you need to generate a random ID per component simply to "remember" where the data for each component is located in Redux?