大致代码如下
dataSource = React.useMemo(一个 generator function)
let faultState = useInfiniteVirtualScroll({ dataSource, }) // 自定义 hook 。
retrue ( 根据 faultState 渲染的 jsx)
大致就是这些代码,在组件的 generator function 还未完成时销毁组件,react 会报一个
/Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function./
就是组件都销毁你还改变 state,目前尝试
React.useEffect(() => {
return () => {
faultState= null as any
dataSource = null as any
}
}, [])
没有效果,求思路
1
4ark 2021-10-14 14:32:47 +08:00
|
2
erwin985211 OP @4ark 思路确实是这样了,我仔细找了是我找的组件的问题已经给它提 bug
|