LeetCode-OpenSource/rxjs-hooks

I cant calc the dom size

fuwei-1993 opened this issue · 4 comments

useObservable is never use in useEffect, but i wanna calc the dom size without some event

Please provide some codes to show your usecase, I'm hardly understand your problem.

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])

It seems that rxjs-hooks isn't suitable for this case. So you may have to do the thing in your own style.

ok tks