02_lesson: create separate selector for selectAllPosts
parent
365bfa6db4
commit
0ea7837958
|
@ -1,7 +1,8 @@
|
|||
import { useSelector } from "react-redux";
|
||||
import { selectAllPosts } from "./postsSlice";
|
||||
|
||||
const PostsList = () => {
|
||||
const posts = useSelector((state) => state.posts);
|
||||
const posts = useSelector(selectAllPosts);
|
||||
|
||||
const renderedPosts = posts.map((post) => (
|
||||
<article key={post.id}>
|
||||
|
|
|
@ -19,4 +19,6 @@ const postsSlice = createSlice({
|
|||
reducers: {},
|
||||
});
|
||||
|
||||
export const selectAllPosts = (state) => state.posts;
|
||||
|
||||
export default postsSlice.reducer;
|
||||
|
|
Loading…
Reference in New Issue