We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如果我的页面有很多很多的倒计时组件,onUpdate 的触发频率太高,但往往我只需要一秒才触发一次,如此高的触发频率,加上我页面有很多的倒计时组件,这对我的页面性能有非常大的挑战。当有50个左右的倒计时组件,页面往往就很卡了。一下是我的代码片段 ` import { View, Text } from '@tarojs/components' import { CountDown } from '@nutui/nutui-react-taro' import { useCallback, useState, useTransition } from 'react'
export default function CustomCountdown(p: { endTime: number onEnd?: () => void }) {
const [isPending, startTransition] = useTransition(); const [restTime, setRestTime] = useState({ d: 0, h: 0, m: 0, s: 0 }) const onUpdate = useCallback((time) => { console.log(time) startTransition(() => setRestTime(time)) }, []) return ( {restTime.d > 0 ? {restTime.d}天 : 距结束 } <View className='w-[24px] h-[24px] text-center leading-[24px] rounded-[6px]' style={{ backgroundColor: 'var(--nutui-color-primary)' }}>{restTime.h < 10 ? 0${restTime.h} : restTime.h} : <View className='w-[24px] h-[24px] text-center leading-[24px] rounded-[6px]' style={{ backgroundColor: 'var(--nutui-color-primary)' }}>{restTime.m < 10 ? 0${restTime.m} : restTime.m} : <View className='w-[24px] h-[24px] text-center leading-[24px] rounded-[6px]' style={{ backgroundColor: 'var(--nutui-color-primary)' }}>{restTime.s < 10 ? 0${restTime.s} : restTime.s} ) } `
0${restTime.h}
0${restTime.m}
0${restTime.s}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
这个功能解决了什么问题?
如果我的页面有很多很多的倒计时组件,onUpdate 的触发频率太高,但往往我只需要一秒才触发一次,如此高的触发频率,加上我页面有很多的倒计时组件,这对我的页面性能有非常大的挑战。当有50个左右的倒计时组件,页面往往就很卡了。一下是我的代码片段
`
import { View, Text } from '@tarojs/components'
import { CountDown } from '@nutui/nutui-react-taro'
import { useCallback, useState, useTransition } from 'react'
export default function CustomCountdown(p: {
endTime: number
onEnd?: () => void
}) {
const [isPending, startTransition] = useTransition();
const [restTime, setRestTime] = useState({
d: 0,
h: 0,
m: 0,
s: 0
})
const onUpdate = useCallback((time) => {
console.log(time)
startTransition(() => setRestTime(time))
}, [])
return (
{restTime.d > 0
? {restTime.d}天
: 距结束
}
<View className='w-[24px] h-[24px] text-center leading-[24px] rounded-[6px]' style={{ backgroundColor: 'var(--nutui-color-primary)' }}>{restTime.h < 10 ?
0${restTime.h}
: restTime.h}:
<View className='w-[24px] h-[24px] text-center leading-[24px] rounded-[6px]' style={{ backgroundColor: 'var(--nutui-color-primary)' }}>{restTime.m < 10 ?
0${restTime.m}
: restTime.m}:
<View className='w-[24px] h-[24px] text-center leading-[24px] rounded-[6px]' style={{ backgroundColor: 'var(--nutui-color-primary)' }}>{restTime.s < 10 ?
0${restTime.s}
: restTime.s})
}
`
你期望的组件设计是怎样的?
The text was updated successfully, but these errors were encountered: