use-asynk-resource
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

useAsynkResource

Example

import { useAsyncResource } from "use-asynk-resource";
import { Suspense } from "react";

const App = () => {
  const userResource = useAsyncResource(() => loadUser(...));

  return (
    <Suspense fallback={<>loading...</>}>
      <User resource={userResource} />
    </Suspense>
  )
};

const Resource = ({ resource }) => {
  const user = resource.read()

  return <div>{user.displayName}</div>
}

Installation

# npm
npm i use-async-resource

# yarn
yarn add use-async-resource

Package Sidebar

Install

npm i use-asynk-resource

Weekly Downloads

7

Version

1.0.8

License

MIT

Unpacked Size

13 kB

Total Files

10

Last publish

Collaborators

  • danuel