All files / react useReachBottom.taro.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22        1x         1x     1x 1x     1x     1x    
import { useReachBottom as _useReachBottom } from './useReachBottom'
import { useEffect, useRef } from 'react'
import { useReachBottom as useTaroReachBottom } from '@tarojs/taro'
 
export const useReachBottom: typeof _useReachBottom = (
  callback,
  // 小程序下该项在页面配置中的 onReachBottomDistance 设置
  _offset,
) => {
  const ref = useRef<any>()
 
  // 立即触发一次回调
  useEffect(() => {
    callback()
  }, [])
 
  useTaroReachBottom(callback)
 
  // 小程序下始终相对于窗口,ref 无实际作用,仅起兼容作用
  return ref
}