Skip to content

initialNumToRender prop added to WheelPicker FlatList props #2521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/components/sectionsWheelPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export type SectionsWheelPickerProps = {
* Row text style
*/
textStyle?: TextStyle;
/**
* Android, flatList props suite for big data section. Solve the bug that section isn't render all the values after value pick.
*/
androidBigDataSection?: boolean;
disableRTL?: boolean;
testID?: string;
};
Expand All @@ -43,7 +47,7 @@ export type SectionsWheelPickerProps = {
*/

const SectionsWheelPicker = (props: SectionsWheelPickerProps) => {
const {sections, itemHeight, numberOfVisibleRows, activeTextColor, inactiveTextColor, textStyle, disableRTL, testID} =
const {sections, itemHeight, numberOfVisibleRows, activeTextColor, inactiveTextColor, textStyle, disableRTL, testID, androidBigDataSection} =
props;

const wheelPickerProps = {
Expand All @@ -60,11 +64,19 @@ const SectionsWheelPicker = (props: SectionsWheelPickerProps) => {

const renderSections = () =>
_.map(sections, (section, index) => {
const sectionItemsLength = section?.items?.length;
const androidBigSection = Constants.isAndroid && androidBigDataSection;
return (
<WheelPicker
disableRTL={shouldDisableRTL}
key={index}
testID={`${testID}.${index}`}
flatListProps={
androidBigSection
? {initialNumToRender: sectionItemsLength, maxToRenderPerBatch: sectionItemsLength}
: undefined
}
style={androidBigSection ? styles.androidSectionWheelPicker : undefined}
{...wheelPickerProps}
{...section}
/>
Expand All @@ -85,5 +97,8 @@ export default asBaseComponent<SectionsWheelPickerProps>(SectionsWheelPicker);
const styles = StyleSheet.create({
disableRTL: {
flexDirection: 'row-reverse'
},
androidSectionWheelPicker: {
flex: 0
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
{"name": "textStyle", "type": "TextStyle", "description": "Row text style"},
{"name": "xxx", "type": "xxxx", "description": "xxxxx"},
{"name": "testID", "type": "string", "description": "The component test id"},
{"name": "faderProps", "type": "FaderProps", "description": "Custom props for fader."}
{"name": "faderProps", "type": "FaderProps", "description": "Custom props for fader."},
{"name": "androidBigDataSection", "type": "boolean", "description": "Android, flatList props suite for big data section. Solve the bug that section isn't render all the values after value pick."}
],
"snippet": [
"<SectionsWheelPicker sections={sections$1}/>"
Expand Down