I have a feed slice:
const feedSlice = createSlice({
name: 'feed',
initialState: {
reposteds: repostedsAdapter.getInitialState(),
comments: commentsAdapter.getInitialState(),
authors: authorsAdapter.getInitialState(),
groups: groupsAdapter.getInitialState(),
posts: postsAdapter.getInitialState(),
lastPostId: undefined,
loading: true,
error: false,
},
reducers: {
postUpdate: (state, { payload }) => {
postsAdapter.updateOne(state.posts, payload);
},
},
});
And I create a selector for posts and other adapters from documentation about entityAdapter:
export const postsSelector = postsAdapter
.getSelectors(({ feed }) => feed.posts);
When I render a list of posts I get Ids selector for render list:
const postsIds = useSelector((state) => postsSelector.selectIds(state));
And in post component I get all needed data with selectors:
const post = useSelector((state) => postsSelector.selectById(state, postId));
const group = useSelector((state) => groupsSelector.selectById(state, post.groupId));
const author = useSelector((state) => authorsSelector.selectById(state, post.authorId));
const reposted = useSelector((state) => repostedsSelector.selectById(state, post.repostedId));
And after changing the post, by calling the action "updatePost" from the feedSlice code, the entire list of posts is rerendered. Why are my selectors not working, what am I doing wrong?