What We Learned Optimizing Base UI: Patterns You Can Steal for Faster React Apps
summary
Base UI migrates from context-heavy renders to a selector-backed store (custom or libraries like Zustand) using useSyncExternalStore so each option subscribes only to its own isFavorite selector, eliminating broad re-renders. Detached triggers and a handle + payload API centralize popups and reuse one DOM shell, cutting initial mount time by over 50%. React Compiler increases bundle size ~26% so it’s skipped. Additional wins come from reducing allocations (module-scope constants, prefer for loops on hot paths) and batching DOM reads/writes to avoid layout thrashing.
AI-written summary · about
