A lightweight React hook that wraps async data fetching with a useState-like interface. Version 1.0.2 provides a simple API returning loading, data, and error states. No built-in caching or deduplication; intended for simple per-component data fetching where minimal overhead is needed. Ships TypeScript definitions.
npm install use-queryNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of useQuery hook with loading, data, and error states.
Implement manual caching via React state or use a library like SWR/React Query for automatic deduplication.
Wrap the async function in useCallback or define it outside the component.
Migrate to react-query or swr for caching, deduplication, and better performance.
Check loading state before using data, or use optional chaining: data?.property
Stabilize the query function with useCallback or a ref