I created selectors to get a list of users like so:
const selectGroup = (state) => state.group;
const selectGroupUsers = createSelector(
[selectGroup],
(group) => group.get('users').toJS()
)
I use it as follows:
const users = useSelector(selectGroupUsers);
These work fine.
Now I am trying to get specific user info using a dynamic path:
const selectUser = createSelector(
[selectGroup, (_, path)],
(group, path) => group.getIn(path).toJS()
)
I use this as follows:
const path = ['users', 5, 'data'] // this is a dynamic array value from props
const userData = useSelector(state => selectUser(state, path));
This works, however I get many redux warnings:
Selector unknown returned a different result when called with the same
parameters. This can lead to unnecessary rerenders.
How do I resolve this?