Function: useClassList()
function useClassList(stack, selector): object;
Defined in: react/src/hooks/class.ts:86
Hook to retrieve a list of classes from a stack based on a selector. Maintains a real-time list of classes matching the selector.
Parameters
| Parameter | Type | Description |
|---|---|---|
stack | string | The name of the stack to query. |
selector | { [key: string]: any; } | Mango selector to filter classes. |
Returns
object
Object containing the list of classes, loading state, and error.
| Name | Type | Defined in |
|---|---|---|
classList | Class[] | react/src/hooks/class.ts:214 |
error | null | react/src/hooks/class.ts:214 |
loading | boolean | react/src/hooks/class.ts:214 |
Example
const ClassList = () => {
const { classList, loading } = useClassList('my-stack', {
name: { $regex: '^User' }
});
if (loading) return <div>Loading...</div>;
return (
<ul>
{classList.map(cls => <li key={cls.id}>{cls.name}</li>)}
</ul>
);
};