Skip to content

Commit 5cb6a43

Browse files
fix: add missing style mapping on flatlist (#321)
* fix: add missing style mapping on flatlist * fix: add test for missing className
1 parent d490d59 commit 5cb6a43

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/__tests__/native/className-with-style.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ test("View with multiple className properties where inline style takes precedenc
9999
]);
100100
});
101101

102+
test("FlatList: className should map to style", () => {
103+
registerCSS(`.bg-red { background-color: red; }`);
104+
105+
const component = render(
106+
<FlatList
107+
testID={testID}
108+
data={[]}
109+
renderItem={() => null}
110+
className="bg-red"
111+
/>,
112+
).getByTestId(testID);
113+
114+
expect(component.props.style).toStrictEqual({ backgroundColor: "#f00" });
115+
});
116+
102117
/**
103118
* Tests for style={undefined} not destroying computed className styles.
104119
*

src/components/FlatList.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { copyComponentProperties } from "./copyComponentProperties";
1111

1212
const mapping: StyledConfiguration<typeof RNFlatList> = {
13+
className: "style",
1314
ListFooterComponentClassName: "ListFooterComponentStyle",
1415
ListHeaderComponentClassName: "ListHeaderComponentStyle",
1516
columnWrapperClassName: "columnWrapperStyle",

0 commit comments

Comments
 (0)