You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
XFlow/packages/xflow-core/src/command-contributions/components/context.tsx
Lines 22 to 55 in b7cdb99
这段代码中用匿名函数 WrappedComponent 包裹AppContext.Provider的用意是什么?
因为每次运行component的function,WrappedComponent都会指向一个新的匿名函数,也就意味着最终返回的 每次都是一个不同的Component,这导致节点在每次重绘(移动位置/连线/断开连线)时都会发生 unmount/mount;
这使得节点Component的生命周期非常短暂,在节点渲染组件中使用 React.useMemo / React.useCallback 等定义的带缓存能力的变量被重复计算。
设计如此?
Beta Was this translation helpful? Give feedback.
All reactions