Awesome Reviewers

When building React UIs that can be hidden/shown (startup screens, side panels, modals, drawers, activity shells), design for correct state + correct side effects across transitions.

Rules 1) Preserve state when possible: If the user should keep their current context (selected conversation/session, drafts, etc.), prefer keeping the component mounted and switching to a hidden/visible mode rather than unmounting. 2) But manage side effects explicitly on hide: Hidden mode should reliably:

Example pattern (hidden vs one-time bootstrap)

function Page() {
  const [loaded, setLoaded] = useState(false);
  const startup = useHubStartup();
  const hubReady = startup.transport === 'connected' && startup.hub.state === 'ready';
  const hubFailed = startup.transport === 'connected' && startup.hub.state === 'failed';

  useEffect(() => {
    if (hubReady) setLoaded(true);
  }, [hubReady]);

  return (
    loaded ? (
      <Activity mode={hubReady ? 'visible' : 'hidden'}>
        <App />
      </Activity>
    ) : (
      <HubStartupScreen {...startup} />
    )
  );
}

function useRemoteEnvironmentBootstrap() {
  const didBootstrapRef = useRef(false);

  useEffect(() => {
    if (!didBootstrapRef.current) {
      didBootstrapRef.current = true;
      // one-time selection/navigation bootstrap
    }
    // always refresh active environment on reconnect
  }, [/* reconnect state */]);
}

Checklist to apply in reviews