useQueue ​
Hook that manages a queue
utilities
test coverage
Last changed: last month
Installation ​
Library
CLI
Manual
typescript
import { useQueue } from '@siberiacancode/reactuse';
Usage ​
typescript
const { queue, add, remove, clear, first, last, size } = useQueue([1, 2, 3]);
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
initialValue? | Value[] | [] | The initial value of the queue |
Returns
UseQueueReturn
Type declaration ​
typescript
export interface UseQueueReturn<Value> {
/** Get the first element of the queue */
first: Value;
/** Get the last element of the queue */
last: Value;
/** The current queue */
queue: Value[];
/** Get the size of the queue */
size: number;
/** Add an element to the queue */
add: (element: Value) => void;
/** Clear the queue */
clear: () => void;
/** Remove an element from the queue */
remove: () => Value;
}
Source ​
Source • DemoContributors ​
D
H