hooks/async
Here are all async hooks.
Use @zl-asica/react
or @zl-asica/react/hooks
for all hooks.
Example
tsx
import { useFetch } from '@zl-asica/react';
const MyComponent = () => {
const { data, error, loading } = useFetch<{ message: string }>(
'https://api.example.com/endpoint'
);
if (loading) return <p>Loading...</p>;
if (error) return <p>Error: {error.message}</p>;
return <p>Data: {data?.message}</p>;
};