Skip to content
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

Allow passing flatListProps #21

Merged
merged 4 commits into from Oct 2, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions src/Gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ export default class Gallery extends PureComponent {
onLongPress: PropTypes.func,
removeClippedSubviews: PropTypes.bool,
imageComponent: PropTypes.func,
errorComponent: PropTypes.func
errorComponent: PropTypes.func,
flatListProps: PropTypes.object,
};

static defaultProps = {
removeClippedSubviews: true,
imageComponent: undefined,
scrollViewStyle: {}
scrollViewStyle: {},
flatListProps: {
windowSize: 3,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should set this windowSize value directly where we render Flatlist to make sure this isn't overriden when the users use flatListProps prop.
Or, we would have to merge the default value and the user's one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Makes sense. The soonest I'll be able to fix this is on Monday.

}
};

imageRefs = new Map();
Expand Down
7 changes: 5 additions & 2 deletions src/libraries/ViewPager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export default class ViewPager extends PureComponent {
removeClippedSubviews: PropTypes.bool,
onPageSelected: PropTypes.func,
onPageScrollStateChanged: PropTypes.func,
onPageScroll: PropTypes.func
onPageScroll: PropTypes.func,
flatListProps: PropTypes.object,
};

static defaultProps = {
Expand All @@ -27,7 +28,8 @@ export default class ViewPager extends PureComponent {
scrollEnabled: true,
pageDataArray: [],
initialListSize: 10,
removeClippedSubviews: true
removeClippedSubviews: true,
flatListProps: {},
};

pageCount = 0; // Initialize to avoid undefined error
Expand Down Expand Up @@ -255,6 +257,7 @@ export default class ViewPager extends PureComponent {
style={[style, { flex: 1 }]}
{...gestureResponder}>
<FlatList
{...this.props.flatListProps}
style={[{ flex: 1 }, scrollViewStyle]}
ref={'innerFlatList'}
keyExtractor={this.keyExtractor}
Expand Down