1.0.1 • Published 5 years ago

use-suspense-today v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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.