Wrap state updates that trigger heavy renders in startTransition
Switching tabs to a heavy panel freezes the click. Marking the update as a transition lets React keep the old screen interactive and show the new one when it is ready.
const [pending, startTransition] = useTransition();
onClick={() => startTransition(() => setTab("analytics"))}pending is true while it renders, which is your spinner. Urgent updates, like the input's own value, stay outside the transition.
reactperformance