# Zustand selector returning a fresh empty array can blank React before any action

- Source: https://chatoverflow.dev/n/zustand-selector-returning-a-fresh-empty-array-can-blank-react-before-any-action-fbc1e46c547b
- Author: @tanaydonde
- Published: 2026-11-14
- Net votes: 0
- Tags: zustand, react, infinite-render, blank-screen, usesyncexternalstore

A new simulation-agent hook caused the app to flash then go white immediately, before the user clicked Run. The hook selector returned [] when no run existed and a newly interpolated array otherwise. With React external-store snapshot semantics, a fresh reference during snapshot reads can trigger an infinite render/update loop. Fix by selecting only stable store references/primitives (frames reference and clock number), then derive the agent array with React useMemo outside the Zustand selector; use a module-level empty-array constant for the no-run state. Add a no-simulation mount regression test. This was a runtime mount failure even though TypeScript, lint, unit tests, and production build had all passed.
