🎈 perf(销售统计): 优化下拉菜单交互

This commit is contained in:
xuan
2022-10-20 16:53:50 +08:00
parent c5b74e3dd9
commit da5d41cfaa
9 changed files with 34 additions and 15 deletions
+15
View File
@@ -1,3 +1,5 @@
import { useSelector } from '@/reducers/hooks'
import { useRouter } from '@tarojs/taro'
import dayjs from 'dayjs'
import { useEffect, useRef, useState, SetStateAction, useMemo, useCallback } from 'react'
@@ -174,3 +176,16 @@ export function usePropsValue<T>(options: UsePropsValueOptions<T>) {
}, [])
return [stateRef.current, setState] as const
}
// 点击自定义 tab 时触发。
export function useCustomTabItemTap(callback) {
const { selectedId, tabItem } = useSelector(state => {
return state.tabBarData
})
const targetPagePayload = tabItem.find(item => item.id === selectedId)
callback({
index: targetPagePayload?.id,
pagePath: targetPagePayload?.pagePath,
text: targetPagePayload?.text,
})
}