Skip to content

Commit 99b36ce

Browse files
committed
fix: maybe fix framer bug
Signed-off-by: Innei <[email protected]>
1 parent 06edd77 commit 99b36ce

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/components/layout/header/internal/Activity.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
useActivity,
1313
} from '~/atoms/activity'
1414
import { FloatPopover } from '~/components/ui/float-popover'
15+
import useDebounceValue from '~/hooks/common/use-debounce-value'
1516
import { apiClient } from '~/lib/request'
1617
import { useAggregationSelector } from '~/providers/root/aggregation-data-provider'
1718

@@ -99,15 +100,15 @@ export function Activity() {
99100

100101
const ownerName = useAggregationSelector((data) => data.user.name)
101102
const memoProcessName = useMemo(
102-
() => ({ processName: data?.processName || '' }),
103-
[data?.processName],
103+
() => ({ processName: activity?.processName || '' }),
104+
[activity?.processName],
104105
)
105-
if (!data) {
106-
return null
107-
}
106+
108107
const { processName, media } = activity
109-
if (!appLabels[processName]) {
110-
console.log('Not collected process name: ', processName)
108+
const debounceProcess = useDebounceValue(processName, 300)
109+
110+
if (!appLabels[debounceProcess]) {
111+
console.log('Not collected process name: ', debounceProcess)
111112
}
112113

113114
return (

src/components/ui/number-transition/NumberSmoothTransition.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
import { AnimatePresence, m } from 'framer-motion'
44

55
import { microdampingPreset } from '~/constants/spring'
6+
import useDebounceValue from '~/hooks/common/use-debounce-value'
67

78
export const NumberSmoothTransition = (props: {
89
children: string | number
910
}) => {
1011
const { children } = props
12+
const debouncedChildren = useDebounceValue(children, 300)
1113
return (
12-
<AnimatePresence mode="popLayout">
14+
<AnimatePresence mode="popLayout" initial={false}>
1315
<m.span
14-
key={children}
16+
key={debouncedChildren}
1517
initial={{
1618
opacity: 0,
1719
y: -16,
@@ -23,10 +25,11 @@ export const NumberSmoothTransition = (props: {
2325
exit={{
2426
opacity: 0,
2527
y: -16,
28+
position: 'absolute',
2629
}}
2730
transition={microdampingPreset}
2831
>
29-
{children}
32+
{debouncedChildren}
3033
</m.span>
3134
</AnimatePresence>
3235
)

0 commit comments

Comments
 (0)