We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
可在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依赖传空数组做成持久化。
The text was updated successfully, but these errors were encountered:
要打印变化后的size1,自己给size1包层ref就行了 类似这样: const ref4size1 = useRef(size1); ref4size1.current = size1;
Sorry, something went wrong.
从使用上来讲 我觉得如果组件内部能解决这个问题会更好一点
No branches or pull requests
可在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依赖传空数组做成持久化。
The text was updated successfully, but these errors were encountered: