Skip to content

Commit 9f452b0

Browse files
committed
fix: 处理ActionSheet/Badge/List/SegmentedControl/SpeedDial/TransitionImage 组件ts类型报错
1 parent 1501430 commit 9f452b0

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

packages/core/src/ActionSheet/item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
TextStyle,
99
StyleSheet,
1010
Text,
11-
TouchableOpacity,
1211
GestureResponderEvent,
1312
} from 'react-native';
1413

@@ -23,6 +22,7 @@ export interface ActionSheetItemProps {
2322
/** 有触摸操作时显示出来的底层的颜色 */
2423
underlayColor?: string;
2524
onPress?: (event: GestureResponderEvent) => void;
25+
children?: React.ReactNode;
2626
}
2727

2828
export interface ActionSheetItemState {}

packages/core/src/Badge/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface BadgeProps extends ViewProps {
2929
/** 标记颜色 */
3030
color?: colors.Colors | string;
3131
/** 文本内容 */
32-
text?: string | Element;
32+
text?: string | React.ReactNode;
3333
/**
3434
* 设置圆角,默认 `12`
3535
*/

packages/core/src/List/index.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ export default class List extends React.PureComponent<ListProps, ListState> {
9494
size,
9595
// eslint-disable-next-line @typescript-eslint/no-unused-vars
9696
extra,
97-
ListHeaderComponent,
9897
title,
98+
ListHeaderComponent,
9999
...otherProps
100100
} = this.props;
101101
const props = {} as ListProps & FlatListProps<{}>;
@@ -126,13 +126,17 @@ export default class List extends React.PureComponent<ListProps, ListState> {
126126
if (!flat) {
127127
return (
128128
<View {...otherProps}>
129-
{header}
130-
{((renderItem && (!data || data.length === 0)) ||
131-
(!renderItem && (!children || React.Children.toArray(children).length === 0))) &&
132-
otherProps.ListEmptyComponent}
133-
{(props.data || []).map((item, idx) =>
134-
React.cloneElement((props.renderItem && props.renderItem({ item, index: idx })) || <View />, { key: idx }),
135-
)}
129+
<>
130+
{header}
131+
{((renderItem && (!data || data.length === 0)) ||
132+
(!renderItem && (!children || React.Children.toArray(children).length === 0))) &&
133+
otherProps.ListEmptyComponent}
134+
{(props.data || []).map((item, idx) =>
135+
React.cloneElement((props.renderItem && props.renderItem({ item, index: idx })) || <View />, {
136+
key: idx,
137+
}),
138+
)}
139+
</>
136140
</View>
137141
);
138142
}

packages/core/src/SegmentedControl/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export interface SegmentedControlState {
1919
selectedIndex: number;
2020
}
2121

22-
export default class SegmentedControl<T> extends Component<SegmentedControlProps<T>, SegmentedControlState> {
22+
export default class SegmentedControl<T extends React.ReactPortal> extends Component<
23+
SegmentedControlProps<T>,
24+
SegmentedControlState
25+
> {
2326
constructor(props: SegmentedControlProps<T>) {
2427
super(props);
2528
this.state = {

packages/core/src/SpeedDial/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface PanXY extends Animated.Value {
2525
_value: number;
2626
}
2727

28-
export interface SpeedDialProps extends ViewProps {
28+
export interface SpeedDialProps {
2929
/** 显示的图标 [默认显示, 展开显示] */
3030
icon?: icoType;
3131
/** 盒子样式 */

packages/core/src/TransitionImage/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type ImageProps = RNImageProps & {
2222
placeholderStyle?: StyleProp<ViewStyle>;
2323
transition?: boolean;
2424
transitionDuration?: number;
25+
children?: React.ReactNode;
2526
};
2627

2728
type ImageState = {

0 commit comments

Comments
 (0)