pure-virtual-list
v0.0.4
Published
This package provides a pure React Virtual List.
Downloads
25
Readme
React + Pure Virtual List
This package provides a pure React Virtual List.
Getting Started
pnpm i pure-virtual-list
Use it in your component
import { VirtualList } from 'pure-virtual-list';
// list template
const ListItem = (item: unknown, index: number) => {
return <div key={index}>{(item as {id: number; key: string;}).key}</div>;
};
const App = () => {
// mock data
const items = Array.from({ length: 1000 }, (_, i) => ({ id: i, key: `Item ${i}` }));
return (
<VirtualList
data={items}
renderItem={ListItem}
itemHeight={50}
containerHeight={300}
buffer={4}
/>
)
}
export default AppExpanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
- Configure the top-level
parserOptionsproperty like this:
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}- Replace
plugin:@typescript-eslint/recommendedtoplugin:@typescript-eslint/recommended-type-checkedorplugin:@typescript-eslint/strict-type-checked - Optionally add
plugin:@typescript-eslint/stylistic-type-checked - Install eslint-plugin-react and add
plugin:react/recommended&plugin:react/jsx-runtimeto theextendslist
