docs(canvas): clarify editing guards and projection lifetimes
This commit is contained in:
@@ -19,9 +19,11 @@ export function useNodeInternalsUpdate(id:string){
|
||||
// 首个节点创建store级batch,每次挂载取得本id的owner;清理仅释放该owner。
|
||||
useEffect(()=>{
|
||||
let batch=batches.get(scope);if(!batch){batch=createNodeInternalsBatch(update);batches.set(scope,batch);}
|
||||
// batch 首次创建时捕获 update;同 store 后续使用者沿用该更新器,不在每次 effect 中替换。
|
||||
const owner=batch.acquire(id);lease.current=owner;
|
||||
return()=>{owner.dispose();if(lease.current===owner)lease.current=undefined;};
|
||||
},[scope,update,id]);
|
||||
// 回调通过ref读取当前租约,避免调用方保存旧闭包后继续刷新已卸载节点。
|
||||
// 回调通过ref读取当前租约;旧调用者保存的同一回调,在本组件 id 改变后会转向新 id 的租约。
|
||||
// effect 尚未安装/已清理则无动作;它不把回调永久绑定到最初 id。
|
||||
return useCallback(()=>lease.current?.invalidate(),[]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user