Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@codemotion/react-tiny-virtual-list
Advanced tools
Readme
A tiny but mighty list virtualization library, with zero dependencies 💪
Check out the demo for some examples.
Using npm:
npm install react-tiny-virtual-list --save
ES6, CommonJS, and UMD builds are available with each distribution. For example:
import VirtualList from 'react-tiny-virtual-list';
You can also use a global-friendly UMD build:
<script src="react-tiny-virtual-list/umd/react-tiny-virtual-list.js"></script>
<script>
var VirtualList = window.VirtualList;
...
</script>
import React from 'react';
import {render} from 'react-dom';
import VirtualList from 'react-tiny-virtual-list';
const data = ['A', 'B', 'C', 'D', 'E', 'F', ...];
render(
<VirtualList
width='100%'
height={600}
itemCount={data.length}
itemSize={50} // Also supports variable heights (array or function getter)
renderItem={({index, style}) =>
<div key={index} style={style}> // The style property contains the item's absolute position
Letter: {data[index]}, Row: #{index}
</div>
}
/>,
document.getElementById('root')
);
Property | Type | Required? | Description |
---|---|---|---|
width | Number or String* | ✓ | Width of List. This property will determine the number of rendered items when scrollDirection is 'horizontal' . |
height | Number or String* | ✓ | Height of List. This property will determine the number of rendered items when scrollDirection is 'vertical' . |
itemCount | Number | ✓ | The number of items you want to render |
renderItem | Function | ✓ | Responsible for rendering an item given it's index: ({index: number, style: Object}): React.PropTypes.node . The returned element must handle key and style. |
itemSize | ✓ | Either a fixed height/width (depending on the scrollDirection), an array containing the heights of all the items in your list, or a function that returns the height of an item given its index: (index: number): number | |
scrollDirection | String | Whether the list should scroll vertically or horizontally. One of 'vertical' (default) or 'horizontal' . | |
scrollOffset | Number | Can be used to control the scroll offset; Also useful for setting an initial scroll offset | |
overscanCount | Number | Number of extra buffer items to render above/below the visible items. Tweaking this can help reduce scroll flickering on certain browsers/devices. | |
onScroll | Function | Callback invoked whenever the scroll offset changes within the inner scrollable region. It has the following signature: (scrollTop: number, event: React.UIEvent<HTMLDivElement>) . |
* Width may only be a string when scrollDirection
is 'vertical'
. Similarly, Height may only be a string if scrollDirection
is 'horizontal'
This method force recomputes the item sizes after the specified index (these are normally cached).
VirtualList
has no way of knowing when its underlying data has changed, since it only receives a itemSize property. If the itemSize is a number
, this isn't an issue, as it can compare before and after values and automatically call recomputeSizes
internally.
However, if you're passing a function to itemSize
, that type of comparison is error prone. In that event, you'll need to call recomputeSizes
manually to inform the VirtualList
that the size of its items has changed.
Found an issue? Please report it along with any relevant details to reproduce it.
Feature requests / pull requests are welcome, though please take a moment to make sure your contributions fits within the scope of the project. Learn how to contribute
This library draws inspiration from react-virtualized, and is meant as a bare-minimum replacement for the List component. If you're looking for a tiny, lightweight and dependency-free list virtualization library that supports variable heights, you're in the right place! If you're looking for something that supports more use-cases, I highly encourage you to check out react-virtualized instead, it's a fantastic library ❤️
react-tiny-virtual-list is available under the MIT License.
FAQs
A tiny but mighty list virtualization component, with zero dependencies 💪
The npm package @codemotion/react-tiny-virtual-list receives a total of 1 weekly downloads. As such, @codemotion/react-tiny-virtual-list popularity was classified as not popular.
We found that @codemotion/react-tiny-virtual-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.