diff --git a/02_lesson_starter/src/features/posts/PostsList.js b/02_lesson_starter/src/features/posts/PostsList.js index 817ac40..b30ec33 100644 --- a/02_lesson_starter/src/features/posts/PostsList.js +++ b/02_lesson_starter/src/features/posts/PostsList.js @@ -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) => (
diff --git a/02_lesson_starter/src/features/posts/postsSlice.js b/02_lesson_starter/src/features/posts/postsSlice.js index 989fbf5..e0efeb5 100644 --- a/02_lesson_starter/src/features/posts/postsSlice.js +++ b/02_lesson_starter/src/features/posts/postsSlice.js @@ -19,4 +19,6 @@ const postsSlice = createSlice({ reducers: {}, }); +export const selectAllPosts = (state) => state.posts; + export default postsSlice.reducer;