-
[OPIK-6098] [FE] fix: move setActiveProject out of ProjectPage render (#6404)
发布于
2026-04-21 12:41:06 +00:00 - [OPIK-6098] [FE] fix: move setActiveProject out of ProjectPage render
Calling setActiveProject during render (in the isError branch) mutated the
zustand store and triggered re-renders of every subscriber — including
DemoProjectBanner — while ProjectPage itself was still rendering. React
flagged it with the "Cannot update a component while rendering a different
component" warning and, under error conditions, it contributed to a visible
re-render loop.Collapse both writes (URL-drift reassert and error-clear) into a single
useEffect that computes the target from isPending/isError/data and writes
only when the store differs. Pure render, no cross-component setState.Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
- fix(project-page): hold Outlet until store catches up with URL
Children rendered with a stale activeProjectId for one frame between
useProjectById resolving and the sync useEffect firing, which kicked off
queries against the previous project. Gate the Outlet on
activeProjectId === projectId. The gate sits after the error branch so
a URL that 404s still renders NoData instead of spinning on the loader
(we deliberately don't write on error, so activeProjectId wouldn't catch
up to an invalid id otherwise).Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Co-authored-by: Claude Opus 4.7 (1M context) noreply@anthropic.com
下载附件