react-components/packages/useAsync at develop · bolasblack/react-components

@c4/use-async

GitHub Repository: https://github.com/bolasblack/react-components/tree/develop/packages/useAsync

<style>{`.sbdocs .markdown-only { display: none !important; }`}</style>

For better reading experience, please visit{' '} Storybook .

import { Canvas, Meta } from '@storybook/addon-docs/blocks' import * as useAsyncStories from './src/useAsync.stories' import * as useAsyncFnFactoryStories from './src/useAsyncFnFactory.stories'

Usage

useAsync

A hook to load data/do asynchronous operations.

Will call function once component mounted, once deps changed:

  • will re-call function;
  • will re-generate reRun function.

useAsyncFnFactory

A hook to load data/do asynchronous operations.

Will not call function automatically, once deps changed:

  • will not re-call function;
  • will call fnFactory to try re-generate async fn.