There should be a short delay (200ms to 500ms) before showing a loading spinner, and if the operation completes in that time you can avoid showing it at all. But if it takes longer than that, the spinner should be shown for a minimum of 500ms or so, to avoid a sudden flash of the spinner.
I wrote a React hook called usePending[1] for this once. It's surprisingly difficult to get right.
I wrote a React hook called usePending[1] for this once. It's surprisingly difficult to get right.
[1] https://gist.github.com/cmmartti/4f7833292b9d277685fc0813532...