From 3f9b4e27fc6557d76a64856d3acdd7b3b41a18ad Mon Sep 17 00:00:00 2001 From: moh1434 Date: Tue, 17 Jan 2023 14:08:31 +0300 Subject: [PATCH] fix render all PostsExcerpts issue --- 08_lesson/src/features/posts/PostsList.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/08_lesson/src/features/posts/PostsList.js b/08_lesson/src/features/posts/PostsList.js index a4bbd43..9262dca 100644 --- a/08_lesson/src/features/posts/PostsList.js +++ b/08_lesson/src/features/posts/PostsList.js @@ -3,18 +3,26 @@ import { useGetPostsQuery } from './postsSlice'; const PostsList = () => { const { - data: posts, + postsIds, isLoading, isSuccess, isError, error - } = useGetPostsQuery('getPosts') + } = useGetPostsQuery('getPosts', { + selectFromResult: ({ data, isLoading, isSuccess, isError, error }) => ({ + postsIds: data?.ids, + isLoading, + isSuccess, + isError, + error, + }), + }) let content; if (isLoading) { content =

"Loading..."

; } else if (isSuccess) { - content = posts.ids.map(postId => ) + content = postsIds?.map(postId => ) } else if (isError) { content =

{error}

; }