docs(workspace): explain component state and async ownership

This commit is contained in:
2026-11-12 16:14:21 +08:00
parent cc2172319e
commit 65c54e7b9e
7 changed files with 19 additions and 1 deletions
@@ -17,6 +17,7 @@ const ActiveBoardContext = createContext<{
/** 在工作台布局内保持元数据,useMemo稳定Context对象,避免只因父渲染就通知全部使用方。 */
export function ActiveBoardProvider({ children }: { children: ReactNode }) {
// Provider 本身不监听路由/登出,也不推断哪条异步结果较新;发布、清空及身份核对由调用方负责。
const [board, setBoard] = useState<ActiveBoard>(null);
const value = useMemo(() => ({ board, setBoard }), [board]);
return <ActiveBoardContext.Provider value={value}>{children}</ActiveBoardContext.Provider>;