recently I've just started to read RTK Query's document in the redux.js.org and understood the doc's main project doesn't show the Posts in CodeSandbox and just [object Object] is obvioused except of the Posts list which should being loaded by the fake server included in the default project . secondly I couldn't managed the error in PostsList page (the Page which is included in the redux main project (simple social media)) .
features/posts/PostsList.js
export const PostList = () => {
const {
data: posts = [],
isSuccess,
isLoading,
isError,
error,
} = useGetPostsQuery()
const orderedPosts = useMemo(() => {
console.log(posts)
const ordered = posts.posts.slice()
ordered.sort((a, b) => b.date.localeCompare(a.date))
return ordered
}, [posts])
just got the [] as the posts value then this error appears "Cannot read properties of undefined (reading 'slice')"
and the whole the main project of redux is accessible right in this link rtk-query-basics