React Redux Toolkit Tips
Introduction
Taken from YouTube https://www.youtube.com/watch?v=NqzdVN2tyvQ
Tip 1
Instead of using
const posts = useSelector((state) => state.posts);
We can use
// In the component
const posts = useSelector(selectAllPosts)
// In the Slice
export const selectAllPosts = (state) => state.posts;