use-suspense-today
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

use-suspense-today

Use React Suspense today, with any data fetching library

NPM JavaScript Style Guide

Install

npm install --save use-suspense-today

Usage

import * as React from 'react'
import { useSuspense } from 'use-suspense-today'
 
const Child = () => {
  const { loading, data } = useApiThatIsNotSuspenseReady();
  useSuspense(loading);
  return <section>{data}</section>;
};
 
const Parent = () => {
  return (
    <React.Suspense fallback={<div>Loading...</div>}>
      <Child />
    </React.Suspense>
  );
};

Check out unit tests for a better example.

License

MIT © Hermanya


This hook is created using create-react-hook.

Package Sidebar

Install

npm i use-suspense-today

Weekly Downloads

43

Version

1.0.1

License

MIT

Unpacked Size

547 kB

Total Files

27

Last publish

Collaborators

  • hermanya