🎈 perf(销售统计): 优化下拉菜单交互
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user