Skip to content

Commit ad3babc

Browse files
committed
fix(avatar): cycles issue
1 parent d168d1a commit ad3babc

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/components/avatar/avatar.animation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
getStyleProperties,
1616
} from '../../helpers/utils/animation';
1717
import * as AvatarPrimitives from '../../primitives/avatar';
18-
import { useInnerAvatarContext } from './avatar';
18+
import { useInnerAvatarContext } from './avatar.context';
1919
import type {
2020
AvatarFallbackAnimation,
2121
AvatarImageAnimation,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { createContext } from '../../helpers/utils';
2+
import type { AvatarContextValue } from './avatar.types';
3+
4+
/**
5+
* Avatar context provider and hook
6+
* Provides size, color, and animation state to child components
7+
*/
8+
export const [AvatarProvider, useInnerAvatarContext] =
9+
createContext<AvatarContextValue>({
10+
name: 'AvatarContext',
11+
});

src/components/avatar/avatar.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ImageSourcePropType, ImageStyle } from 'react-native';
33
import Animated from 'react-native-reanimated';
44
import { Text } from '../../helpers/components';
55
import { useThemeColor } from '../../helpers/theme';
6-
import { childrenToString, createContext } from '../../helpers/utils';
6+
import { childrenToString } from '../../helpers/utils';
77
import * as AvatarPrimitives from '../../primitives/avatar';
88
import {
99
useAvatarFallbackAnimation,
@@ -14,10 +14,10 @@ import {
1414
AVATAR_DEFAULT_ICON_SIZE,
1515
AVATAR_DISPLAY_NAME,
1616
} from './avatar.constants';
17+
import { AvatarProvider, useInnerAvatarContext } from './avatar.context';
1718
import avatarStyles, { styleSheet } from './avatar.styles';
1819
import type {
1920
AvatarColor,
20-
AvatarContextValue,
2121
AvatarFallbackProps,
2222
AvatarFallbackRef,
2323
AvatarImageProps,
@@ -33,11 +33,6 @@ const AnimatedFallback = Animated.createAnimatedComponent(
3333
AvatarPrimitives.Fallback
3434
);
3535

36-
export const [AvatarProvider, useInnerAvatarContext] =
37-
createContext<AvatarContextValue>({
38-
name: 'AvatarContext',
39-
});
40-
4136
/**
4237
* Hook to access Avatar primitive root context
4338
* Provides access to avatar status and other root-level state

0 commit comments

Comments
 (0)