Skip to content

Commit f13f13c

Browse files
fix: prevent unnecessary animation on Tab component mount
Fixes a bug where the Tab animation would run on initial mount even when already at the target state. This caused unnecessary animation work and potential visual glitches. Changes: - Added isInitialMount ref to track first render - Skip animation on mount, immediately set value instead - Subsequent changes animate normally This ensures underlines appear instantly on first render and only animate when the active state actually changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 47fd55c commit f13f13c

File tree

1 file changed

+9
-0
lines changed
  • app/component-library/components-temp/Tabs/Tab

1 file changed

+9
-0
lines changed

app/component-library/components-temp/Tabs/Tab/Tab.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@ const Tab: React.FC<TabProps> = ({
2424
}) => {
2525
const tw = useTailwind();
2626
const scaleAnim = useRef(new Animated.Value(isActive ? 1 : 0)).current;
27+
const isInitialMount = useRef(true);
2728

2829
useEffect(() => {
30+
// Skip animation on initial mount - just set the value
31+
if (isInitialMount.current) {
32+
isInitialMount.current = false;
33+
scaleAnim.setValue(isActive && !isDisabled ? 1 : 0);
34+
return;
35+
}
36+
37+
// Animate on subsequent changes
2938
Animated.timing(scaleAnim, {
3039
toValue: isActive && !isDisabled ? 1 : 0,
3140
duration: AnimationDuration.Fast,

0 commit comments

Comments
 (0)