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-salvager

v6.0.0

Published

Reuse row elements when displaying large datasets.

Downloads

82

Readme

react-salvager

build status coverage status npm version npm downloads

sauce test status

A React port of salvager:

Reuse row elements when displaying large datasets. This is beneficial to performance since the number of row elements rendered to the DOM is fixed, no matter how big the dataset is.

The algorithm used in this port is simpler than the one used in the original salvager module. This came about after thinking more carefully about the minimal set of mutable state this port needed.

It's also worth noting that I'm not personally using this port in a production situation yet :smirk:

Installation

$ npm install react-salvager --save

There are also UMD builds available via unpkg:

  • https://unpkg.com/react-salvager/dist/react-salvager.js
  • https://unpkg.com/react-salvager/dist/react-salvager.min.js

If you use these, make sure you have already included React as a dependency.

Usage

There is a working example contained in the example/ dir. To view it, start the server via npm start, then point a browser at http://localhost:3000/example/.

Note that the server itself is actually a webpack-dev-server with react hot loading enabled, so you can use this setup for development too.

API

Props

  • bufferSize - Optional Number of row rendered to the DOM. Defaults to 50.
  • rowWrapperStyle - Optional Extra style added to the row wrapper.
  • spacerStyle - Optional Extra style added to the spacer.
  • visibleAreaStyle - Optional Extra style added to the visible area (root node).

Example

// Note that row items can be any valid React element.

<Salvager
  bufferSize={25}
  rowWrapperStyle={{
    listStyleType: 'none',
    marginBottom: 0,
    marginTop: 0,
    paddingLeft: 0
  }}
  visibleAreaStyle={{
    backgroundColor: '#fff',
    border: '1px solid #ddd',
    height: 400,
    width: 300
  }}
>
  <div key="1">Item 1</div>
  <div key="2">Item 2</div>
  ...
  <div key="9999">Item 9999</div>
  <div key="10000">Item 10000<div>
</Salvager>

Testing

Karma is used to run the tests in real browsers, since we need to read offsetHeight and something like jsdom doesn't implement what we need yet.

To run the tests locally using Chrome:

$ npm test -- local

Travis will also run the tests via Sauce Labs when changes are pushed. To view the code coverage report, open coverage/html/index.html in a browser.

License

MIT