docs: update documentation for custom data-fetching hooks

This commit is contained in:
Aaron William Po
2023-12-03 03:05:34 -05:00
parent c5b7cb5a43
commit 0353f82c20
21 changed files with 115 additions and 89 deletions

View File

@@ -8,6 +8,23 @@ interface UseBreweryPostsByUserParams {
userId: string;
}
/**
* A custom hook to fetch brewery posts by a specific user.
*
* @param options The options to use when fetching brewery posts.
* @param options.pageSize The number of brewery posts to fetch per page.
* @param options.userId The ID of the user to fetch brewery posts for.
* @returns An object with the following properties:
*
* - `breweryPosts`: The brewery posts fetched from the API.
* - `error`: The error that occurred while fetching the data.
* - `isAtEnd`: A boolean indicating whether all data has been fetched.
* - `isLoading`: A boolean indicating whether the data is being fetched.
* - `isLoadingMore`: A boolean indicating whether more data is being fetched.
* - `pageCount`: The total number of pages of data.
* - `setSize`: A function to set the size of the data.
* - `size`: The size of the data.
*/
const useBreweryPostsByUser = ({ pageSize, userId }: UseBreweryPostsByUserParams) => {
const fetcher = async (url: string) => {
const response = await fetch(url);