Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c8aef9

Browse files
committed
component rendered timeout
1 parent 27e74ac commit 8c8aef9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/components/Queue/QueueCommands.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ const QueueCommands: React.FC<QueueCommandsProps> = ({
400400
/>
401401
);
402402

403-
// Use setTimeout to ensure the component has rendered
403+
// Use a small delay to ensure the component has rendered
404+
// 50ms is generally enough for React to complete a render cycle
404405
setTimeout(() => {
405406
// Extract options from the rendered select element
406407
const selectElement = hiddenRenderContainer.querySelector('select');
@@ -420,7 +421,7 @@ const QueueCommands: React.FC<QueueCommandsProps> = ({
420421
// Clean up
421422
root.unmount();
422423
document.body.removeChild(hiddenRenderContainer);
423-
}, 0);
424+
}, 50); // Increased timeout to ensure render completes
424425
}}
425426
tabIndex={0}
426427
onKeyDown={(e) => {
@@ -442,7 +443,8 @@ const QueueCommands: React.FC<QueueCommandsProps> = ({
442443
/>
443444
);
444445

445-
// Use setTimeout to ensure the component has rendered
446+
// Use a small delay to ensure the component has rendered
447+
// 50ms is generally enough for React to complete a render cycle
446448
setTimeout(() => {
447449
// Extract options from the rendered select element
448450
const selectElement = hiddenRenderContainer.querySelector('select');
@@ -471,7 +473,7 @@ const QueueCommands: React.FC<QueueCommandsProps> = ({
471473
// Clean up
472474
root.unmount();
473475
document.body.removeChild(hiddenRenderContainer);
474-
}, 0);
476+
}, 50); // Increased timeout to ensure render completes
475477
}
476478
}}
477479
>

0 commit comments

Comments
 (0)