Replies: 2 comments 2 replies
-
If you write that inline it should already have the correct type without you writing anything. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for the swift response! What about if I want to define the selector in my So basically // apiSlice.ts
export selectPostsByUserId = createSelector(
res => res.data,
(res, userId) => userId,
(data, userId) => data?.filter(post => post.user === userId) ?? emptyArray
)
// ComponentOne.tsx
const { userPosts } = useGetPostsQuery(undefined, {
selectFromResult: res => ({
userPosts: selectPostsByUserId(res, userId),
}),
});
// ComponentTwo.tsx
const { userPosts } = useGetPostsQuery(undefined, {
selectFromResult: res => ({
userPosts: selectPostsByUserId(res, userId),
}),
}); Or is ☝️ not a good pattern to follow? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In the Selecting Values from Results example, what is the proper way to type the
res
argument ofres => res.data
increateSelector
?Beta Was this translation helpful? Give feedback.
All reactions