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

Added prop to suppress bounded size exception #709

Merged
merged 3 commits into from
Apr 8, 2022
Merged
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
15 changes: 12 additions & 3 deletions src/core/RecyclerListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ export interface RecyclerListViewProps {
applyWindowCorrection?: (offsetX: number, offsetY: number, windowCorrection: WindowCorrection) => void;
onItemLayout?: (index: number) => void;
windowCorrectionConfig?: { value?: WindowCorrection, applyToInitialOffset?: boolean, applyToItemScroll?: boolean };

//This can lead to inconsistent behavior. Use with caution.
//If set to true, recyclerlistview will not measure itself if scrollview mounts with zero height or width.
//If there are no following events with right dimensions nothing will be rendered.
suppressBoundedSizeException?: boolean;
}

export interface RecyclerListViewState {
Expand Down Expand Up @@ -557,16 +562,20 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
}

private _onSizeChanged = (layout: Dimension): void => {
if (layout.height === 0 || layout.width === 0) {
if (!this.props.suppressBoundedSizeException) {
throw new CustomError(RecyclerListViewExceptions.layoutException);
} else {
return;
}
}
if (!this.props.canChangeSize && this.props.layoutSize) {
return;
}
const hasHeightChanged = this._layout.height !== layout.height;
const hasWidthChanged = this._layout.width !== layout.width;
this._layout.height = layout.height;
this._layout.width = layout.width;
if (layout.height === 0 || layout.width === 0) {
throw new CustomError(RecyclerListViewExceptions.layoutException);
}
if (!this._initComplete) {
this._initComplete = true;
this._initTrackers(this.props);
Expand Down