Skip to content

Commit bcdae23

Browse files
committed
chore: use Object.assign instead of direct assign
1 parent 4de31b1 commit bcdae23

File tree

4 files changed

+27
-39
lines changed

4 files changed

+27
-39
lines changed

packages/uikit-react-native-foundation/src/components/Icon/index.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ReactNode } from 'react';
1+
import React from 'react';
22
import { Image, ImageStyle, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
33

44
import { FileType, convertFileTypeToMessageType, getFileIconFromMessageType } from '@sendbird/uikit-utils';
@@ -17,10 +17,8 @@ type Props = {
1717
style?: StyleProp<ImageStyle>;
1818
containerStyle?: StyleProp<ViewStyle>;
1919
};
20-
const Icon: ((props: Props) => ReactNode) & {
21-
Assets: typeof IconAssets;
22-
File: typeof FileIcon;
23-
} = ({ icon, color, size = 24, containerStyle, style }) => {
20+
21+
const Icon = ({ icon, color, size = 24, containerStyle, style }: Props) => {
2422
const sizeStyle = sizeStyles[size as SizeFactor] ?? { width: size, height: size };
2523
const { colors } = useUIKitTheme();
2624
return (
@@ -68,6 +66,7 @@ const sizeStyles = createStyleSheet({
6866
},
6967
});
7068

71-
Icon.Assets = IconAssets;
72-
Icon.File = FileIcon;
73-
export default Icon;
69+
export default Object.assign(Icon, {
70+
Assets: IconAssets,
71+
File: FileIcon,
72+
});

packages/uikit-react-native-foundation/src/styles/createScaleFactor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ const createScaleFactor = (deviceWidth = DESIGNED_DEVICE_WIDTH) => {
1010
return (dp: number) => PixelRatio.roundToNearestPixel(dp * rangedRatio);
1111
};
1212

13-
createScaleFactor.updateScaleFactor = (scaleFactor: (dp: number) => number) => {
14-
DEFAULT_SCALE_FACTOR = scaleFactor;
15-
};
16-
1713
export let DEFAULT_SCALE_FACTOR = createScaleFactor();
18-
export default createScaleFactor;
14+
export default Object.assign(createScaleFactor, {
15+
updateScaleFactor: (scaleFactor: (dp: number) => number) => {
16+
DEFAULT_SCALE_FACTOR = scaleFactor;
17+
},
18+
});

packages/uikit-react-native-foundation/src/ui/Avatar/index.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ReactNode, useState } from 'react';
1+
import React, { useState } from 'react';
22
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
33

44
import { conditionChaining } from '@sendbird/uikit-utils';
@@ -10,24 +10,15 @@ import useUIKitTheme from '../../theme/useUIKitTheme';
1010
import AvatarGroup from './AvatarGroup';
1111
import AvatarIcon from './AvatarIcon';
1212

13-
type SubComponents = {
14-
Group: typeof AvatarGroup;
15-
Icon: typeof AvatarIcon;
16-
};
1713
type Props = {
1814
uri?: string;
1915
size?: number;
2016
square?: boolean;
2117
muted?: boolean;
2218
containerStyle?: StyleProp<ViewStyle>;
2319
};
24-
const Avatar: ((props: Props) => ReactNode) & SubComponents = ({
25-
uri,
26-
square,
27-
muted = false,
28-
size = 56,
29-
containerStyle,
30-
}) => {
20+
21+
const Avatar = ({ uri, square, muted = false, size = 56, containerStyle }: Props) => {
3122
const { colors, palette } = useUIKitTheme();
3223
const [loadFailure, setLoadFailure] = useState(false);
3324

@@ -74,6 +65,7 @@ const styles = createStyleSheet({
7465
},
7566
});
7667

77-
Avatar.Group = AvatarGroup;
78-
Avatar.Icon = AvatarIcon;
79-
export default Avatar;
68+
export default Object.assign(Avatar, {
69+
Group: AvatarGroup,
70+
Icon: AvatarIcon,
71+
});

packages/uikit-react-native-foundation/src/ui/Header/index.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ReactNode } from 'react';
1+
import React from 'react';
22
import { TouchableOpacity, TouchableOpacityProps, View } from 'react-native';
33
import { useSafeAreaInsets } from 'react-native-safe-area-context';
44

@@ -26,11 +26,7 @@ export type HeaderProps = BaseHeaderProps<
2626
>;
2727

2828
const AlignMapper = { left: 'flex-start', center: 'center', right: 'flex-end' } as const;
29-
const Header: ((props: HeaderProps) => ReactNode) & {
30-
Button: typeof HeaderButton;
31-
Title: typeof HeaderTitle;
32-
Subtitle: typeof HeaderSubtitle;
33-
} = ({
29+
const Header = ({
3430
children,
3531
titleAlign,
3632
title = null,
@@ -41,7 +37,7 @@ const Header: ((props: HeaderProps) => ReactNode) & {
4137
clearTitleMargin = false,
4238
clearStatusBarTopInset = false,
4339
statusBarTopInsetAs = 'padding',
44-
}) => {
40+
}: HeaderProps) => {
4541
const { topInset, defaultTitleAlign, defaultHeight } = useHeaderStyle();
4642

4743
const { colors } = useUIKitTheme();
@@ -183,7 +179,8 @@ const styles = createStyleSheet({
183179
},
184180
});
185181

186-
Header.Button = HeaderButton;
187-
Header.Title = HeaderTitle;
188-
Header.Subtitle = HeaderSubtitle;
189-
export default Header;
182+
export default Object.assign(Header, {
183+
Button: HeaderButton,
184+
Title: HeaderTitle,
185+
Subtitle: HeaderSubtitle,
186+
});

0 commit comments

Comments
 (0)