diff --git a/lib/hooks/actions-queue.js b/lib/hooks/actions-queue.js --- a/lib/hooks/actions-queue.js +++ b/lib/hooks/actions-queue.js @@ -8,6 +8,7 @@ function useActionsQueue( performAction: (item: T) => mixed | Promise, + canProcess: boolean = true, ): MessageQueueHook { const [queue, setQueue] = React.useState<$ReadOnlyArray>([]); const isProcessing = React.useRef(false); @@ -32,11 +33,11 @@ ); React.useEffect(() => { - if (isProcessing.current || queue.length === 0) { + if (isProcessing.current || queue.length === 0 || !canProcess) { return; } void process(queue[0]); - }, [process, queue]); + }, [process, queue, canProcess]); return { enqueue }; }