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

Undefined index while rendering sticky #674

Merged
merged 4 commits into from
Jan 27, 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
21 changes: 12 additions & 9 deletions src/core/sticky/StickyObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,19 @@ export default abstract class StickyObject<P extends StickyObjectProps> extends
}

private _renderSticky(): JSX.Element | JSX.Element[] | null {
const _stickyData: any = this.props.getDataForIndex(this.currentStickyIndex);
const _stickyLayoutType: string | number = this.props.getLayoutTypeForIndex(this.currentStickyIndex);
const _extendedState: object | undefined = this.props.getExtendedState();
const _rowRenderer: ((type: string | number, data: any, index: number, extendedState?: object)
=> JSX.Element | JSX.Element[] | null) = this.props.getRowRenderer();
if (this.props.overrideRowRenderer) {
return this.props.overrideRowRenderer(_stickyLayoutType, _stickyData, this.currentStickyIndex, _extendedState);
} else {
return _rowRenderer(_stickyLayoutType, _stickyData, this.currentStickyIndex, _extendedState);
if (this.currentStickyIndex !== undefined) {
const _stickyData: any = this.props.getDataForIndex(this.currentStickyIndex);
const _stickyLayoutType: string | number = this.props.getLayoutTypeForIndex(this.currentStickyIndex);
const _extendedState: object | undefined = this.props.getExtendedState();
const _rowRenderer: ((type: string | number, data: any, index: number, extendedState?: object)
=> JSX.Element | JSX.Element[] | null) = this.props.getRowRenderer();
if (this.props.overrideRowRenderer) {
return this.props.overrideRowRenderer(_stickyLayoutType, _stickyData, this.currentStickyIndex, _extendedState);
} else {
return _rowRenderer(_stickyLayoutType, _stickyData, this.currentStickyIndex, _extendedState);
}
}
return null;
}

private _getAdjustedOffsetY(offsetY: number): number {
Expand Down