question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for detecting what range of results are displayed by the list

See original GitHub issue

Thank you for this awesome set of Components ❤️. I have the following feature request, “Support for detecting what range of results are displayed by the list”

Scenario

I am using the components at the moment to render a large finite list. I have a user base that is used to pagination and they are comfortable with how it helps them orient themselves on what they are viewing, the selected page let’s them know where they are within the list.

In case of an infinite List displaying a large finite list I understand that I can display them the total count and the Scroll bar position helps them orient themselves on the relative position in the list,

In order to address the change aversion, I want to be able to derive currentPageNumber out of the visible items in the List

<ItemListPageInfo>{currentPageNumber} of {this.props.itemList.total}</ItemListPageInfo>

Code example

Here is the complete code relevant to this for context.

<ItemListContainer>
    <InfiniteScrollWrapper>
        <InfiniteLoader
            isRowLoaded={this.isRowLoaded}
            loadMoreRows={this.loadMoreRows}
            rowCount={this.props.itemList.total}
            minimumBatchSize={100}
            threshold={10}
        >
            {({ onRowsRendered, registerChild }) => (
                <AutoSizer disableWidth>
                    {({ height }) => (
                        <List
                            ref={registerChild}
                            height={height}
                            onRowsRendered={onRowsRendered}
                            rowCount={this.props.itemList.total}
                            estimatedRowSize={92}
                            noRowsRenderer={this.noRowsRenderer}
                            overscanRowCount={10}
                            rowHeight={92}
                            rowRenderer={this.rowRenderer}
                            width={256}
                        />
                    )}
                </AutoSizer>
            )}
        </InfiniteLoader>
    </InfiniteScrollWrapper>
    <ItemListFooter>
        <ItemCreateButton>+ Create Item</ItemCreateButton>
        <ItemListPageInfo>{currentPageNumber} of {this.props.itemList.total}</ItemListPageInfo>
    </ItemListFooter>
</ItemListContainer>

Interface suggestion

Add a new public method for List component

getVisibleItemsInfo({ excludePartiallyVisibleItems: ?boolean}) which will provide information about the currently displayed visible Items Return Information {startIndex:number, endIndex:number} Which can be used to render information to the user like

  • Viewing items 10 to 20
  • 10 of 20123

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
soneymathewcommented, Feb 5, 2018

Ah my bad I didn’t think that was an API, gotta read the code better ☹️ thanks a lot !

So wrap the function

    onRowsRendered={wrap(
        onRowsRendered,
        this.wrappedOnRowsRendered,
    )}

Sniff for changes to calculate page number

    wrappedOnRowsRendered = (onRowsRendered, ref) => {
        const { startIndex, stopIndex } = ref;
        console.log(
            `StartIndex: ${startIndex} - StopIndex: ${stopIndex}`,
        );
        // put it in the state or calculate pagenumber here
        return onRowsRendered(ref);
    };
Read more comments on GitHub >

github_iconTop Results From Across the Web

Look up values in a list of data - Microsoft Support
Look up data in Excel to find data in a list and verify that it's correct. Then, perform calculations or display results with...
Read more >
4.5.1 Calculating the range and interquartile range
This table displays the results of Rank of data points. The information is grouped by Rank (appearing as row headers), Value (appearing as ......
Read more >
Help - PubMed - NIH
A citation sensor displays suggested results for searches that include terms characteristic of citation searching, e.g., author names, journal ...
Read more >
Use Smart Fill in Sheets to automate data entry - Google Support
Smart Fill will detect patterns and make suggestions to help automate data entry. ... from a given list of full names or finding...
Read more >
Play HDR video on Mac - Apple Support
In general, HDR quality is better on HDR displays that offer better brightness and contrast ratio, which results in a wider dynamic range....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found