Skip to content

Commit 7f3eb1f

Browse files
committed
fix: ensure static component methods are copied
1 parent dfbf076 commit 7f3eb1f

17 files changed

+163
-65
lines changed

src/components/ActivityIndicator.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
type StyledProps,
1010
} from "react-native-css";
1111

12+
import { copyComponentProperties } from "./copyComponentProperties";
13+
1214
const mapping: StyledConfiguration<typeof RNActivityIndicator> = {
1315
className: {
1416
target: "style",
@@ -18,10 +20,11 @@ const mapping: StyledConfiguration<typeof RNActivityIndicator> = {
1820
},
1921
};
2022

21-
export function ActivityIndicator(
22-
props: StyledProps<ActivityIndicatorProps, typeof mapping>,
23-
) {
24-
return useCssElement(RNActivityIndicator, props, mapping);
25-
}
23+
export const ActivityIndicator = copyComponentProperties(
24+
RNActivityIndicator,
25+
(props: StyledProps<ActivityIndicatorProps, typeof mapping>) => {
26+
return useCssElement(RNActivityIndicator, props, mapping);
27+
},
28+
);
2629

2730
export default ActivityIndicator;

src/components/Button.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
type StyledProps,
77
} from "react-native-css";
88

9+
import { copyComponentProperties } from "./copyComponentProperties";
10+
911
const mapping: StyledConfiguration<typeof RNButton> = {
1012
className: {
1113
target: false,
@@ -15,8 +17,11 @@ const mapping: StyledConfiguration<typeof RNButton> = {
1517
},
1618
};
1719

18-
export function Button(props: StyledProps<ButtonProps, typeof mapping>) {
19-
return useCssElement(RNButton, props, mapping);
20-
}
20+
export const Button = copyComponentProperties(
21+
RNButton,
22+
(props: StyledProps<ButtonProps, typeof mapping>) => {
23+
return useCssElement(RNButton, props, mapping);
24+
},
25+
);
2126

2227
export default Button;

src/components/FlatList.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ReactNode } from "react";
12
import { FlatList as RNFlatList, type FlatListProps } from "react-native";
23

34
import {
@@ -6,17 +7,25 @@ import {
67
type StyledProps,
78
} from "react-native-css";
89

10+
import { copyComponentProperties } from "./copyComponentProperties";
11+
912
const mapping: StyledConfiguration<typeof RNFlatList> = {
1013
ListFooterComponentClassName: "ListFooterComponentStyle",
1114
ListHeaderComponentClassName: "ListHeaderComponentStyle",
1215
columnWrapperClassName: "columnWrapperStyle",
1316
contentContainerClassName: "contentContainerStyle",
1417
};
1518

16-
export function FlatList<ItemT>(
17-
props: StyledProps<FlatListProps<ItemT>, typeof mapping>,
18-
) {
19+
export const FlatList = copyComponentProperties(RNFlatList, function <
20+
ItemT,
21+
>(props: StyledProps<FlatListProps<ItemT>, typeof mapping>) {
1922
return useCssElement(RNFlatList, props, mapping);
20-
}
23+
}) as unknown as typeof RNFlatList &
24+
(<ItemT>(
25+
props: StyledProps<
26+
FlatListProps<ItemT>,
27+
StyledConfiguration<typeof RNFlatList>
28+
>,
29+
) => ReactNode);
2130

2231
export default FlatList;

src/components/Image.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ import {
66
type StyledProps,
77
} from "react-native-css";
88

9+
import { copyComponentProperties } from "./copyComponentProperties";
10+
911
const mapping: StyledConfiguration<typeof RNImage> = {
1012
className: "style",
1113
};
1214

13-
export function Image(props: StyledProps<ImageProps, typeof mapping>) {
14-
return useCssElement(RNImage, props, mapping);
15-
}
15+
export const Image = copyComponentProperties(
16+
RNImage,
17+
(props: StyledProps<ImageProps, typeof mapping>) => {
18+
return useCssElement(RNImage, props, mapping);
19+
},
20+
);
1621

1722
export default Image;

src/components/ImageBackground.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
type StyledProps,
1010
} from "react-native-css";
1111

12+
import { copyComponentProperties } from "./copyComponentProperties";
13+
1214
const mapping: StyledConfiguration<typeof RNImageBackground> = {
1315
className: {
1416
target: "style",
@@ -18,10 +20,11 @@ const mapping: StyledConfiguration<typeof RNImageBackground> = {
1820
},
1921
};
2022

21-
export function ImageBackground(
22-
props: StyledProps<ImageBackgroundProps, typeof mapping>,
23-
) {
24-
return useCssElement(RNImageBackground, props, mapping);
25-
}
23+
export const ImageBackground = copyComponentProperties(
24+
RNImageBackground,
25+
(props: StyledProps<ImageBackgroundProps, typeof mapping>) => {
26+
return useCssElement(RNImageBackground, props, mapping);
27+
},
28+
);
2629

2730
export default ImageBackground;

src/components/KeyboardAvoidingView.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ import {
99
type StyledProps,
1010
} from "react-native-css";
1111

12+
import { copyComponentProperties } from "./copyComponentProperties";
13+
1214
const mapping: StyledConfiguration<typeof RNKeyboardAvoidingView> = {
1315
className: {
1416
target: "style",
1517
},
1618
};
1719

18-
export function KeyboardAvoidingView(
19-
props: StyledProps<KeyboardAvoidingViewProps, typeof mapping>,
20-
) {
21-
return useCssElement(RNKeyboardAvoidingView, props, mapping);
22-
}
20+
export const KeyboardAvoidingView = copyComponentProperties(
21+
RNKeyboardAvoidingView,
22+
(props: StyledProps<KeyboardAvoidingViewProps, typeof mapping>) => {
23+
return useCssElement(RNKeyboardAvoidingView, props, mapping);
24+
},
25+
);
2326

2427
export default KeyboardAvoidingView;

src/components/Pressable.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ import {
66
type StyledProps,
77
} from "react-native-css";
88

9+
import { copyComponentProperties } from "./copyComponentProperties";
10+
911
const mapping: StyledConfiguration<typeof RNPressable> = {
1012
className: "style",
1113
};
1214

13-
export function Pressable(props: StyledProps<PressableProps, typeof mapping>) {
14-
return useCssElement(RNPressable, props, mapping);
15-
}
15+
export const Pressable = copyComponentProperties(
16+
RNPressable,
17+
(props: StyledProps<PressableProps, typeof mapping>) => {
18+
return useCssElement(RNPressable, props, mapping);
19+
},
20+
);
1621

1722
export default Pressable;

src/components/ScrollView.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ import {
66
type StyledProps,
77
} from "react-native-css";
88

9+
import { copyComponentProperties } from "./copyComponentProperties";
10+
911
const mapping: StyledConfiguration<typeof RNScrollView> = {
1012
className: "style",
1113
contentContainerClassName: "contentContainerStyle",
1214
};
1315

14-
export function ScrollView(
15-
props: StyledProps<ScrollViewProps, typeof mapping>,
16-
) {
17-
return useCssElement(RNScrollView, props, mapping);
18-
}
16+
export const ScrollView = copyComponentProperties(
17+
RNScrollView,
18+
(props: StyledProps<ScrollViewProps, typeof mapping>) => {
19+
return useCssElement(RNScrollView, props, mapping);
20+
},
21+
);
1922

2023
export default ScrollView;

src/components/Switch.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ import {
66
type StyledProps,
77
} from "react-native-css";
88

9+
import { copyComponentProperties } from "./copyComponentProperties";
10+
911
const mapping = {
1012
className: "style",
1113
} satisfies StyledConfiguration<typeof RNSwitch>;
1214

13-
export function Switch(props: StyledProps<SwitchProps, typeof mapping>) {
14-
return useCssElement(RNSwitch, props, mapping);
15-
}
15+
export const Switch = copyComponentProperties(
16+
RNSwitch,
17+
(props: StyledProps<SwitchProps, typeof mapping>) => {
18+
return useCssElement(RNSwitch, props, mapping);
19+
},
20+
);
1621

1722
export default Switch;

src/components/Text.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ import {
66
type StyledProps,
77
} from "react-native-css";
88

9+
import { copyComponentProperties } from "./copyComponentProperties";
10+
911
const mapping = {
1012
className: "style",
1113
} satisfies StyledConfiguration<typeof RNText>;
1214

13-
export function Text(props: StyledProps<TextProps, typeof mapping>) {
14-
return useCssElement(RNText, props, mapping);
15-
}
15+
export const Text = copyComponentProperties(
16+
RNText,
17+
(props: StyledProps<TextProps, typeof mapping>) => {
18+
return useCssElement(RNText, props, mapping);
19+
},
20+
);
1621

1722
export default Text;

0 commit comments

Comments
 (0)