generated from react-component/footer
-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
可在repo内example/collection.tsx文件的onBatchResize函数内添加console.log({ size1 }),观看demo效果。当多次发生resize时,打印的size1始终是第一次渲染时的size1。
原因应该是src/SingleObserver/index.tsx内,onInternalResize用useCallback做了持久化,如果onCollectionResize发生了更新则无法通知onInternalResize做出更新。因此应该加一个
const onCollectionResizeRef = React.useRef(onCollectionResize); onCollectionResizeRef.current = onCollectionResize;
之类的改造;
或者src/Collection.tsx对onBatchResize用ref包装,onResize依赖传空数组做成持久化。
Metadata
Metadata
Assignees
Labels
No labels