withCollection()
Basic Usage
import { withCollection } from 'jason-api';
import { User } from './your-components';
const UserList = ({
data,
isLoading,
refetch,
}: CollectionProps) => (
<div onClick={onDummyAction}>
<h1>
User
{isLoading && <span>Loading...</span>}
</h1>
{(data || []).map(user => (
<User key={user.id} data={user} />
))}
<button onClick={refetch}>Refresh</button>
</div>
);
const EnhancedUserList = withCollection({ resourceType: 'users' })(UserList);
Options
const enhance = withCollection({
resourceType: 'users',
ids: ['12345', '54321'],
expandResourceObjects: false,
});
const EnhancedUsers = enhance(Users);
<EnhancedUsers />
<EnhancedUsers ids={['12345', '54321']} />