Closed
Description
I've got an implementation that looks like this:
// The usual RTK query api declaration above here ^^^
// Export the generated hooks and the API service
export const {
useGetModelQuery,
useGetModelByIdQuery,
useCreateModelMutation,
useUpdateModelMutation,
useDeleteModelMutation,
} = modelApi;
export const useGetModelByPathnameQuery = (pathname) => {
return useGetModelQuery(undefined, {
selectFromResult: ({ data }) => {
return data?.find(({ path }) => path === pathname) || {};
},
});
};
I feel like I'm off the map, All the examples I've found in the documentation declare selectFromResult
in the component, but I don't want to redefine the same selectFromResult
in every one of the dozen or so components that pull this data. What is the prescribed pattern??
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels