use-queue limits the number of data in current state and places the rest of it in a queue.
For example, in @mantine/notifications package number of
notifications that is currently displayed is limited and other new notifications are added to the queue and displayed once
available space appears.
The hook accepts one argument – a configuration object with keys:
initialValues– optional initial values (divided between state and queue according to limit), defaults to empty array
limit– maximum number of items that state can include, every next item after the limit is exceeded is put in queue
state– current state
queue– current queue
add– add any number of items to state or queue
update– apply given function to all items in state and queue, use it to filter, modify or add items
cleanQueue– remove all items from the queue
By default, the hook will get types information from
If you do not provide
initialValues, pass in type for state item: