Request data with fetch and get the loading state, the error and a way to refetch or abort.
This is custom React hooks, you need to follow the Basic Rules when you use it.
Load a post when you click, with the loading state handled by the hook.
const useFetch = <T = unknown>(
url: string,
options?: RequestInit & { autoInvoke?: boolean },
) => {
data: T | null
loading: boolean
error: Error | null
refetch: () => Promise<T | null>
abort: () => void
}