Hook to access the HATEOAS client instance from context.
Must be used within a ResourceProvider component.
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]); // ...} Copy
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]); // ...}
Hook to access the HATEOAS client instance from context.
Must be used within a ResourceProvider component.