React by Patrik

React query wrapper hook

If you use the same query in multiple places, consider adding a wrapper hook to keep your code clean:

function useAllBooks() {
return useQuery("books", getAllBooks)
}
function Component1() {
const {...} = useAllBooks()
return (...)
}
function Component2() {
const {...} = useAllBooks()
return (...)
}

Comments