import { useCallback, useRef, useState } from 'react'

export default function useLoding(maxNum: number) {
  // 初始先加载图片 在加载其他
  const [imgNow, setImgNow] = useState(false)

  const numRef = useRef(0)

  const imgNumFu = useCallback(() => {
    numRef.current += 1

    if (numRef.current === maxNum) setImgNow(true)
  }, [maxNum])

  return {
    imgNow,
    imgNumFu
  }
}
