Wondering what’s next for npm?Check out our public roadmap! »

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

2.0.2 • Public • Published

🛌🎣 Rest Hooks Legacy

CircleCI Coverage Status npm downloads bundle size npm version PRs Welcome

Rest Hooks without Suspense.

resources/ProfileResource.ts

import { Resource } from 'rest-hooks';

export default class ProfileResource extends Resource {
  readonly id: number | undefined = undefined;
  readonly img: string = '';
  readonly fullName: string = '';
  readonly bio: string = '';

  pk() {
    return this.id;
  }
  static urlRoot = '/profiles';
}

ProfileList.tsx

import { useStatefulResource } from '@rest-hooks/legacy';
import { Skeleton, Card, Avatar } from 'antd';
import ProfileResource from 'resources/ProfileResource';

const { Meta } = Card;

function ProfileList() {
  const { data, loading, error } = useStatefulResource(
    ProfileResource.detailShape(),
    {},
  );
  if (error) return <div>Error {error.status}</div>
  return (
    <Card style={{ width: 300, marginTop: 16 }} loading={loading}>
      <Meta
        avatar={
          <Avatar src={data.img} />
        }
        title={data.fullName}
        description={data.bio}
      />
    </Card>
  );
}

Install

npm i @rest-hooks/legacy

DownloadsWeekly Downloads

7,130

Version

2.0.2

License

Apache-2.0

Unpacked Size

57.3 kB

Total Files

12

Last publish

Collaborators

  • avatar
  • avatar