Skip to content

Commit 1ecb77d

Browse files
committed
fix(web): stabilize generate loading shimmer
Avoid creating a new Motion component type inside TextShimmer render. The shared GenerateButton mounts this shimmer when TTS and clone generation begin, and recreating the animated subtree on each render could trigger React DOM removal mismatches on Android Chrome. Use a stable motion.p component for the current shimmer usage while preserving the loading animation.
1 parent 165f0ba commit 1ecb77d

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

apps/web/components/motion-primitives/text-shimmer.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
11
'use client';
22
import { motion } from 'motion/react';
3-
import React, { type JSX, useMemo } from 'react';
3+
import React, { useMemo } from 'react';
44

55
import { cn } from '@/lib/utils';
66

7-
export type TextShimmerProps = {
7+
export interface TextShimmerProps {
88
children: string;
9-
as?: React.ElementType;
109
className?: string;
1110
duration?: number;
1211
spread?: number;
13-
};
12+
}
1413

1514
function TextShimmerComponent({
1615
children,
17-
as: Component = 'p',
1816
className,
1917
duration = 2,
2018
spread = 2,
2119
}: TextShimmerProps) {
22-
const MotionComponent = motion.create(
23-
Component as keyof JSX.IntrinsicElements,
24-
);
25-
2620
const dynamicSpread = useMemo(() => {
2721
return children.length * spread;
2822
}, [children, spread]);
2923

3024
return (
31-
<MotionComponent
25+
<motion.p
3226
animate={{ backgroundPosition: '0% center' }}
3327
className={cn(
3428
'relative inline-block bg-size-[250%_100%,auto] bg-clip-text',
@@ -52,7 +46,7 @@ function TextShimmerComponent({
5246
}}
5347
>
5448
{children}
55-
</MotionComponent>
49+
</motion.p>
5650
);
5751
}
5852

0 commit comments

Comments
 (0)