@hateoas-ts/resource-react - v1.4.0
    Preparing search index...

    Function useClient

    • Hook to access the HATEOAS client instance from context.

      Must be used within a ResourceProvider component.

      Returns Client

      The HATEOAS client instance

      Error if used outside of ResourceProvider

      import { useClient } from '@hateoas-ts/resource-react';
      import type { User } from './types';

      function UserProfile({ userId }: { userId: string }) {
      const client = useClient();

      useEffect(() => {
      client.go<User>(`/api/users/${userId}`).get().then(setUser);
      }, [client, userId]);

      // ...
      }