Nine Pedestrians Mesmerized

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

    4.0.0 • 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/legacy';
    
    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

    4,402

    Version

    4.0.0

    License

    Apache-2.0

    Unpacked Size

    551 kB

    Total Files

    122

    Last publish

    Collaborators

    • ntucker
    • ljharb