Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

@rest-hooks/legacy

1.0.12 • 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

2,650

Version

1.0.12

License

Apache-2.0

Unpacked Size

32.1 kB

Total Files

12

Last publish

Collaborators

  • avatar