npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-measured-grid

v0.2.1

Published

A smoother scrolling virtualized React grid with dynamically measured rows and columns.

Downloads

3

Readme

react-measured-grid

A smoother scrolling virtualized React grid with dynamically measured rows and columns.

react-measured-grid can be a good tool to use when:

  • You want to display data in a tabular format with rows and columns.
  • The height of a row might not be known until after it is rendered by the browser, for example if the content of a cell consists of variable length text that can wrap to an unknown number of lines.
  • The number of rows can be very large, for example tens of thousands of rows.
  • The number of columns is not very large.
  • You want to support relatively smooth forward and backward scrolling.
  • You want the option to easily control column widths and the size of the view window with a combination of inline and selector-based CSS in units other than pixels.

Demos

You can interact with several demos to get an idea of the performance and flexibility this package offers and to compare its behavior to other implementation approaches.

Install

        # Yarn
        yarn add react-measured-grid

        # NPM
        npm install --save react-measured-grid

Usage

If dataArray is an array of arrays of data, for example:

    dataArray = [
      ['gen-0157-C', 'Generator 157, model C; 120 volts, 500 Watts, with extended overload protection', 7],
      ['ptr-0049-F', 'Printer 49 in the F block', 1],
      ...
    ];

Then displaying three columns of data with a MeasuredGrid component can be as simple as:

    <MeasuredGrid
      dataArrayInitial={dataArray}
      columnCountInitial={3}
      columnWidth={['15ex', '45ex', '8ex']}
      viewStyle={{width: 75ex, height: 20ex}}
    />

API

You can read about the full API for more details and options.

Additional features include:

  • Position a specified row at the top, middle, or bottom of the view window.
  • Support for efficiently adding rows to or removing rows from the end of the data.
  • Support for rows that dynamically change height and columns that change width.

Background

MeasuredGrid displays virtualized data, meaning that at any one time it will put in the DOM only those rows in a neighborhood of the rows that can be seen in the scrollable view window.

In contrast, if MeasuredGrid needs to add part of a row to the DOM, it will add the entire row.

This package was inspired by react-virtualized, but is somewhat more directly a fork of react-window.

This package is designed to provide smoother scrolling than react-virtualized, especially smoother backwards scrolling over rows not previously rendered. However react-measured-grid will typically be somewhat less efficient in its virtualization than react-window, which depends on knowing the height of rows and widths of columns in pixels before it decides how to populate the DOM. The difference in efficiency will vary depending on the number of columns and other patterns in the data and on the extent to which you use features of react-measured-grid to tune its performance.

While react-measured-grid borrowed many ideas from those packages, it does not attempt to provide an API that is compatible with either one.

License

MIT © 2020 DavidCary