docs(workspace): explain component state and async ownership
This commit is contained in:
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user