I cant calc the dom size
fuwei-1993 opened this issue · 4 comments
fuwei-1993 commented
useObservable is never use in useEffect, but i wanna calc the dom size without some event
Brooooooklyn commented
Please provide some codes to show your usecase, I'm hardly understand your problem.
fuwei-1993 commented
useEffect(() => {
const virtualListEle: HTMLDivElement = listContainerRef.current
containerHeight$.next(virtualListEle.clientHeight)
const actualRow$ = combineLatest(containerHeight$, props.options$).pipe(
map(([ch, { height }]) => Math.ceil(ch / height)),
)
const dataInViewSlice$ = combineLatest(props.data$, actualRow$).pipe(
map(([data, actualRows]) => data.slice(0, actualRows)),
)
const scrollHeight$ = combineLatest(props.data$, props.options$).pipe(
map(([data, { height }]) => data.length * height),
)
sub.add(
combineLatest(dataInViewSlice$, scrollHeight$).subscribe(
([data, height]) => {
setData(data)
seHeight(height)
},
),
)
return () => {
sub.unsubscribe()
}
}, [listContainerRef.current])zry656565 commented
It seems that rxjs-hooks isn't suitable for this case. So you may have to do the thing in your own style.
fuwei-1993 commented
ok tks