{"id":13725360,"url":"https://github.com/gnir-work/react-window-dynamic-list","last_synced_at":"2025-02-27T13:39:29.654Z","repository":{"id":38989967,"uuid":"252226549","full_name":"gnir-work/react-window-dynamic-list","owner":"gnir-work","description":"A naive approach to virtualizing a dynamically sized list ","archived":false,"fork":false,"pushed_at":"2023-03-06T22:45:32.000Z","size":6366,"stargazers_count":49,"open_issues_count":15,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-18T14:51:26.561Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gnir-work.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-01T16:18:27.000Z","updated_at":"2024-03-13T22:37:31.000Z","dependencies_parsed_at":"2024-06-18T21:21:33.647Z","dependency_job_id":"89c860a6-d920-45f1-a88b-104602519b88","html_url":"https://github.com/gnir-work/react-window-dynamic-list","commit_stats":{"total_commits":106,"total_committers":5,"mean_commits":21.2,"dds":"0.047169811320754707","last_synced_commit":"33183c421f81aa88b8470beef993aab318f5dc79"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnir-work%2Freact-window-dynamic-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnir-work%2Freact-window-dynamic-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnir-work%2Freact-window-dynamic-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnir-work%2Freact-window-dynamic-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gnir-work","download_url":"https://codeload.github.com/gnir-work/react-window-dynamic-list/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241019250,"owners_count":19895219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T01:02:20.509Z","updated_at":"2025-02-27T13:39:29.617Z","avatar_url":"https://github.com/gnir-work.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# react-window-dynamic-list\n\n\u003e Made with the awesome [create-react-library](https://github.com/transitive-bullshit/create-react-library)\n\n[![NPM](https://img.shields.io/npm/v/react-window-dynamic-list.svg)](https://www.npmjs.com/package/react-window-dynamic-list) [![NPM Installs](https://img.shields.io/npm/dw/react-window-dynamic-list?label=NPM%20installs)](https://www.npmjs.com/package/react-window-dynamic-list) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## How is this different from `react-window`?\n\nThis library comes to partly solve the case of rendering dynamically sized items with [react-window](https://github.com/bvaughn/react-window),\nfor more information about the issue please read [this thread](https://github.com/bvaughn/react-window/issues/6).\nBefore you overjoy please read the [limitations](#warning-requirements-and-limitations-warning) of this approach down bellow :sleepy:\n\n## Demo\n\n👉 [check out dynamic list in action](https://gnir-work.github.io/react-window-dynamic-list/)\n\n:pencil2: [Play with the demo in sandbox](https://codesandbox.io/s/react-window-dynamic-list-example-iwvis?file=/src/App.js)\n\n## Install\n\n```bash\nnpm install --save react-window-dynamic-list\n```\n\n## Usage\n\n![Usage Preview](docs/carbon.png)\n\nYep. its that simple :satisfied:\n\n## API\n\nThe API is the same as [VariableSizeList](https://react-window.now.sh/#/api/VariableSizeList) with some small changes and additions.\n\n#### Changes\n\n1. Instead of `itemCount` you must pass `data` ([read more](#additions))\n2. We handle `itemSize` and `estimatedItemSize` for you :sunglasses:\n\n#### Additions\n\n| Property                | Type     | Required? |             Default             | Description                                                                                                                                                  |\n| :---------------------- | :------- | :-------: | :-----------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| data                    | `Object[]` |     ✓     |                                 | All of the data that will be displayed in the list. \u003cbr /\u003eEach `object` must contain an unique `id` field.\u003cbr /\u003eFor example: `[{id: 1, ...}, {id: 2, ....}`] |\n| cache                   | `Object` |     ✓     |                                 | The cache object which the list will use for caching the calculated sizes.\u003cbr /\u003eCheck the [example](#usage) for how to create it.                            |\n| lazyMeasurement         | `boolean` |           |             `true`              | Whether the application should fill the cache in the background.\u003cbr /\u003ePlease note: After each cache clear the application will restart the lazy cache filling (For example after adding or removing an item)\u003cbr/\u003eFor more information read the [caching section](#caching).                       |\n| recalculateItemsOnResize | `Object` |           | `{ width: false, height: false }` | Whether the list should recalculate the items size if its own size has changed. This value __should not__ change from its initial one.\u003cbr/\u003eCurrently the feature is supported but far from perfect, therefore it is disabled by default. |\n| measurementContainerElement | `Function` |           | `({style, children}) =\u003e ReactNode` | A custom container element in which the elements will be rendered for measuring. Especially useful for changing the [scrollbar width](#warning-requirements-and-limitations-warning). \u003cbr/\u003eYou **must** pass the `style` prop to your element. |\n| debug | `boolean` |           | `false` | Whether the measurement layer should be visible, useful for debugging a custom `measurementContainerElement` |\n\n## Implementations details\n\n### TL;DR:\n\nJust in time measurement with caching in the background.\n\n### Details:\n\nThe algorithm is divided into two main concepts:\n\n#### Just in time measurements:\n\nWe measure each item in the list by temporary rendering it with `react-dom` in a different application.\nFor more information please read [this great article](https://medium.com/trabe/measuring-non-rendered-elements-in-react-with-portals-c5b7c51aec25).\n\n#### Caching:\n\nIn order for just in time measurements to be effective we need to cache the measurements.\nCurrently there are two caching modes:\n\n1. Cache only the items that were rendered\n2. On top of caching the rendered items a background task will measure each element and fill the cache.\n   This is the **default behavior** as it gives a significant performance boost, especially in case of manipulating the data before scrolling through it.\n   In exchange there is a very mild slow down in overall performance in the first couple of seconds and after each change to the size of the list.\u003cbr/\u003e\n   :warning: Please note: the lazy cache filling will be triggered in case you call `resetAfterIndex` function of `VariableSizeList`.\n\n## :warning: Requirements and Limitations :warning:\n\n1. Your data doesn't change its size.\n\n   - Your items size must be determined on mount (No `ajax` or images).\n\n2. Currently only supports vertical layout. (didn't have time to implement support for horizontal).\n\n3. All of the styling regarding the items **must** be `inline` or not affected by location in the `DOM`.\n\n4. Changes to the list's scrollbar, especially the width, should also effect the measurement container div.\n   Since we pre render the items in order to measure them the size of the scrollbar is important in the pre rendered item as well. This can be achieved in the following ways:\n\n   1. Make sure all of the scrollbars in the application are styled the same\n   2. Pass a custom measurement container element via the `measurementContainerElement` prop.\n\n## License\n\nMIT © [gnir-work](https://github.com/gnir-work)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnir-work%2Freact-window-dynamic-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgnir-work%2Freact-window-dynamic-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnir-work%2Freact-window-dynamic-list/lists"}