This package has been deprecated

Author message:

Please use @data-client/react instead. https://dataclient.io/docs/api/useLoading

@data-client/hooks
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Networking Hooks

CircleCI Coverage Status npm downloads bundle size npm version PRs Welcome

Composable hooks for networking data

🚨 Repository Deprecated and Moved! 🚨

This repository has been deprecated and is no longer actively maintained. All hooks moved to @data-client/react

Aborts inflight request if the parameters change.

const data = useSuspense(useCancelling(MyEndpoint, { filter }), { filter });

Delays updating the parameters by debouncing. Useful to avoid spamming network requests when parameters might change quickly (like a typeahead field).

const debouncedFilter = useDebounce(filter, 200);
const data = useSuspense(SearchList, { filter: debouncedFilter });

Helps track loading state of imperative async functions.

function Button({ onClick, children, ...props }) {
  const [clickHandler, loading, error] = useLoading(onClick);
  return (
    <button onClick={clickHandler} {...props}>
      {loading ? 'Loading...' : children}
    </button>
  );
}

Package Sidebar

Install

npm i @data-client/hooks

Weekly Downloads

590

Version

0.2.0

License

Apache-2.0

Unpacked Size

50.7 kB

Total Files

29

Last publish

Collaborators

  • ntucker