I want to select data from query result
function useGetItemById(id: string) {
return api.endpoints.getItemList(undefined, {
selectFromResult: ({ data, ...rest }) => ({
...rest,
data: data?.find(item => item.id === id)
})
});
}
...
// But the data type is T[] and not just T
const { data } = useGetItemById('1');
What should I do to get just T?