{"id":22308812,"url":"https://github.com/ratson/react-list-fix","last_synced_at":"2025-03-26T01:29:01.567Z","repository":{"id":57333978,"uuid":"56965896","full_name":"ratson/react-list-fix","owner":"ratson","description":"A versatile infinite scroll React component.","archived":false,"fork":false,"pushed_at":"2019-04-14T01:42:40.000Z","size":649,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T19:16:53.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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ratson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-24T10:26:39.000Z","updated_at":"2019-04-14T01:42:41.000Z","dependencies_parsed_at":"2022-09-21T04:51:23.523Z","dependency_job_id":null,"html_url":"https://github.com/ratson/react-list-fix","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Freact-list-fix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Freact-list-fix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Freact-list-fix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Freact-list-fix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ratson","download_url":"https://codeload.github.com/ratson/react-list-fix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245571300,"owners_count":20637317,"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-12-03T20:15:26.980Z","updated_at":"2025-03-26T01:29:01.545Z","avatar_url":"https://github.com/ratson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# This is a fork\n\nDue to https://github.com/orgsync/react-list/pull/98 was not accepted, and I need a fix for it, so I forked it.\n\nThe main difference from the upstream is this version uses `setTimeout()` for `updateFrame()` to avoid the scrolling issue on Android WebView.\n\nI would recommend trying out the original `react-list` first, switch to this fork unless you see the problem. The fix by no means is a proper fix, but it works for me.\n\n# ReactList\n\nA versatile infinite scroll [React] component.\n\n## Install\n\n```bash\nnpm install react-list-fix --save\n```\n\nReactList depends on React.\n\n## Examples\n\nCheck out [the example page] and the [the example page source] for examples of\ndifferent configurations.\n\nHere's another simple example to get you started.\n\n```js\nimport loadAccount from 'my-account-loader';\nimport React from 'react';\nimport ReactList from 'react-list';\n\nclass MyComponent extends React.Component {\n  state = {\n    accounts: []\n  };\n\n  componentWillMount() {\n    loadAccounts(::this.handleAccounts);\n  }\n\n  handleAccounts(accounts) {\n    this.setState({accounts});\n  }\n\n  renderItem(index, key) {\n    return \u003cdiv key={key}\u003e{this.state.accounts[index].name}\u003c/div\u003e;\n  }\n\n  render() {\n    return (\n      \u003cdiv\u003e\n        \u003ch1\u003eAccounts\u003c/h1\u003e\n        \u003cdiv style={{overflow: 'auto', maxHeight: 400}}\u003e\n          \u003cReactList\n            itemRenderer={::this.renderItem}\n            length={this.state.accounts.length}\n            type='uniform'\n          /\u003e\n        \u003c/div\u003e\n      \u003c/div\u003e\n    );\n  }\n}\n```\n\n## Props\n\n##### axis (defaults to `y`)\n\nThe axis that this list scrolls on.\n\n##### initialIndex\n\nAn index to scroll to after mounting.\n\n##### itemRenderer(index, key)\n\nA function that receives an index and a key and returns the content to be\nrendered for the item at that index.\n\n##### itemsRenderer(items, ref)\n\nA function that receives the rendered items and a ref. By default this element\nis just a `\u003cdiv\u003e`. Generally it only needs to be overridden for use in a\n`\u003ctable\u003e` or other special case. **NOTE: You must set ref={ref} on the component\nthat contains the `items` so the correct item sizing calculations can be made.**\n\n##### itemSizeEstimator(index, cache)\n\nA function that receives an item index and the cached known item sizes and\nreturns an estimated size (height for y-axis lists and width for x-axis lists)\nof that item at that index. This prop is only used when the prop `type` is set\nto `variable` and `itemSizeGetter` is not defined. Use this property when you\ncan't know the exact size of an item before rendering it, but want it to take up\nspace in the list regardless.\n\n##### itemSizeGetter(index)\n\nA function that receives an item index and returns the size (height for y-axis\nlists and width for x-axis lists) of that item at that index. This prop is only\nused when the prop `type` is set to `variable`.\n\n##### length (defaults to `0`)\n\nThe number of items in the list.\n\n##### pageSize (defaults to `10`)\n\nThe number of items to batch up for new renders.\n\n##### scrollParentGetter (defaults to finding the nearest scrollable parent)\n\nA function that returns a DOM Element or Window that will be treated as the\nscrolling container for the list. In most cases this does not need to be set for\nthe list to work as intended. It is exposed as a prop for more complicated uses\nwhere the scrolling container may not initially have an overflow property that\nenables scrolling.\n\n##### threshold (defaults to `100`)\n\nThe number of pixels to buffer at the beginning and end of the rendered list\nitems.\n\n##### type (one of `simple`, `variable`, or `uniform`, defaults to `simple`)\n\n- `simple` This type is...simple. It will not cache item sizes or remove items\nthat are above the viewport. This type is sufficient for many cases when the\nonly requirement is incremental rendering when scrolling.\n\n- `variable` This type is preferred when the sizes of the items in the list\nvary. Supply the `itemSizeGetter` when possible so the entire length of the\nlist can be established beforehand. Otherwise, the item sizes will be cached\nas they are rendered so that items that are above the viewport can be removed as\nthe list is scrolled.\n\n- `uniform` This type is preferred when you can guarantee all of your\nelements will be the same size. The advantage here is that the size of the\nentire list can be calculated ahead of time and only enough items to fill the\nviewport ever need to be drawn. The size of the first item will be used to\ninfer the size of every other item. Multiple items per row are also supported\nwith this type.\n\n##### useStaticSize (defaults to `false`)\n\nSet to `true` if the item size will never change (as a result of responsive\nlayout changing or otherwise). This prop is only used when the prop `type` is\nset to `uniform`. This is an opt-in optimization that will cause the very first\nelement's size to be used for all elements for the duration of the component's\nlife.\n\n##### useTranslate3d (defaults to `false`)\n\nA boolean to determine whether the `translate3d` CSS property should be used for\npositioning instead of the default `translate`. This can help performance on\nmobile devices, but is supported by fewer browsers.\n\n## Methods\n\n##### scrollTo(index)\n\nPut the element at `index` at the top of the viewport. Note that if you aren't\nusing `type='uniform'` or an `itemSizeGetter`, you will only be able to scroll\nto an element that has already been rendered.\n\n##### scrollAround(index)\n\nScroll the viewport so that the element at `index` is visible, but not\nnecessarily at the top. The `scrollTo` note above also applies to this method.\n\n##### getVisibleRange() =\u003e `[firstIndex, lastIndex]`\n\nReturn the indices of the first and last items that are at all visible in the\nviewport.\n\n## FAQ\n\n##### What is \"ReactList failed to reach a stable state.\"?\n\nThis happens when specifying the `uniform` type without actually providing\nuniform size elements. The component attempts to draw only the minimum necessary\nelements at one time and that minimum element calculation is based off the first\nelement in the list. When the first element does not match the other elements,\nthe calculation will be wrong and the component will never be able to fully\nresolve the ideal necessary elements.\n\n##### Why doesn't it work with margins?\n\nThe calculations to figure out element positioning and size get significantly\nmore complicated with margins, so they are not supported. Use a transparent\nborder or padding or an element with nested elements to achieve the desired\nspacing.\n\n##### Why is there no onScroll event handler?\n\nIf you need an onScroll handler, just add the handler to the div wrapping your ReactList component:\n\n```\n\u003cdiv style={{height: 300, overflow: 'auto'}} onScroll={this.handleScroll}\u003e\n  \u003cReactList ... /\u003e\n\u003c/div\u003e\n```\n\n## Development\n\n```bash\nopen index.html\nmake\n```\n\n[React]: https://github.com/facebook/react\n[the example page]: https://orgsync.github.io/react-list/\n[the example page source]: examples/index.es6\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratson%2Freact-list-fix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fratson%2Freact-list-fix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratson%2Freact-list-fix/lists"}