Skip to content

Commit

Permalink
fix: 修改几个组件里children的类型定义方式
Browse files Browse the repository at this point in the history
  • Loading branch information
chj-damon committed Oct 17, 2023
1 parent 2062632 commit b9b5b09
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
52 changes: 26 additions & 26 deletions packages/react-native/src/card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, memo, PropsWithChildren, ReactNode } from 'react';
import React, { FC, memo, ReactNode } from 'react';
import { StyleProp, StyleSheet, ViewStyle } from 'react-native';

import { useTheme } from '@shopify/restyle';
Expand Down Expand Up @@ -27,14 +27,16 @@ export interface CardProps {
containerStyle?: StyleProp<ViewStyle>;
/** 容器内content样式 */
contentStyle?: StyleProp<ViewStyle>;
/** 子组件 */
children?: ReactNode;
}

/**
* Card 组件由Header(可选)/Content/Footer(可选)三部分组成
* @param param0
* @returns
*/
const Card: FC<PropsWithChildren<CardProps>> = ({
const Card: FC<CardProps> = ({
icon,
title,
extra,
Expand Down Expand Up @@ -119,28 +121,26 @@ const Header = memo(
}
);

const Body = memo(
({ footer, contentStyle, children }: Pick<PropsWithChildren<CardProps>, 'footer' | 'contentStyle' | 'children'>) => {
const theme = useTheme<Theme>();
const Body = memo(({ footer, contentStyle, children }: Pick<CardProps, 'footer' | 'contentStyle' | 'children'>) => {
const theme = useTheme<Theme>();

return (
<Box
padding="x2"
style={
footer
? StyleSheet.compose(
{
borderBottomWidth: ONE_PIXEL,
borderBottomColor: theme.colors.border,
paddingBottom: theme.spacing.x2,
},
contentStyle
)
: contentStyle
}
>
{children}
</Box>
);
}
);
return (
<Box
padding="x2"
style={
footer
? StyleSheet.compose(
{
borderBottomWidth: ONE_PIXEL,
borderBottomColor: theme.colors.border,
paddingBottom: theme.spacing.x2,
},
contentStyle
)
: contentStyle
}
>
{children}
</Box>
);
});
6 changes: 3 additions & 3 deletions packages/react-native/src/pressable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* effect is the invocation of `onPress` and `onLongPress` that occur when a
* responder is release while in the "press in" states.
*/
import React, { memo, PropsWithChildren } from 'react';
import React, { memo } from 'react';
import { Pressable as RNPressable, PressableProps as RNPressableProps, StyleProp, ViewStyle } from 'react-native';

import helpers from '../helpers';
Expand All @@ -44,7 +44,7 @@ type Rect = {
export interface PressableProps
extends Pick<
RNPressableProps,
'onPress' | 'onPressIn' | 'onPressOut' | 'onLongPress' | 'disabled' | 'delayLongPress' | 'onLayout'
'onPress' | 'onPressIn' | 'onPressOut' | 'onLongPress' | 'disabled' | 'delayLongPress' | 'onLayout' | 'children'
> {
/** 点击时的不透明度 */
activeOpacity?: number;
Expand All @@ -58,7 +58,7 @@ export interface PressableProps
}

const { px } = helpers;
function Pressable(props: PropsWithChildren<PressableProps>) {
function Pressable(props: PressableProps) {
const {
children,
activeOpacity = 0.6,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/src/swipe-row/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type SwipeRowProps = PropsWithChildren<{
onRemove?: () => Promise<boolean>;
/** 是否覆盖默认操作项 */
overwriteDefaultActions?: boolean;
/** Swiperable自身的样式 */
/** Swipeable自身的样式 */
containerStyle?: StyleProp<ViewStyle>;
/** Swipeable的子组件样式 */
contentContainerStyle?: StyleProp<ViewStyle>;
Expand Down

0 comments on commit b9b5b09

Please sign in to comment.