{"id":26496135,"url":"https://github.com/damonbauer/react-native-get-item-layout-section-list","last_synced_at":"2025-08-10T19:10:31.319Z","repository":{"id":228375504,"uuid":"772933705","full_name":"damonbauer/react-native-get-item-layout-section-list","owner":"damonbauer","description":"Create the getItemLayout prop for a SectionList with React Native","archived":false,"fork":false,"pushed_at":"2025-07-30T20:51:55.000Z","size":1276,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-30T22:59:03.518Z","etag":null,"topics":["getitemlayout","react-native","sectionlist"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/damonbauer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-16T09:27:28.000Z","updated_at":"2025-07-30T20:51:58.000Z","dependencies_parsed_at":"2024-05-01T22:08:25.137Z","dependency_job_id":"7d1624fb-4c68-4bfd-919f-be8814ed7a4f","html_url":"https://github.com/damonbauer/react-native-get-item-layout-section-list","commit_stats":null,"previous_names":["damonbauer/react-native-get-item-layout-section-list"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/damonbauer/react-native-get-item-layout-section-list","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damonbauer%2Freact-native-get-item-layout-section-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damonbauer%2Freact-native-get-item-layout-section-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damonbauer%2Freact-native-get-item-layout-section-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damonbauer%2Freact-native-get-item-layout-section-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/damonbauer","download_url":"https://codeload.github.com/damonbauer/react-native-get-item-layout-section-list/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damonbauer%2Freact-native-get-item-layout-section-list/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269773217,"owners_count":24473563,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["getitemlayout","react-native","sectionlist"],"created_at":"2025-03-20T11:29:25.757Z","updated_at":"2025-08-10T19:10:31.244Z","avatar_url":"https://github.com/damonbauer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-get-item-layout-section-list\n\nCreate the `getItemLayout` prop for a `SectionList` with React Native.\n\n[![NPM Version](https://img.shields.io/npm/v/react-native-get-item-layout-section-list?registry_uri=https%3A%2F%2Fregistry.npmjs.org\u0026logo=npm)](https://www.npmjs.com/package/react-native-get-item-layout-section-list)\n[![NPM Downloads](https://img.shields.io/npm/dm/react-native-get-item-layout-section-list?logo=npm)](https://www.npmjs.com/package/react-native-get-item-layout-section-list)\n![GitHub License](https://img.shields.io/github/license/damonbauer/react-native-get-item-layout-section-list)\n\n* [Motivation](#motivation)\n* [Installation](#installation)\n* [Usage](#usage)\n  * [Basic](#basic)\n  * [Advanced](#advanced)\n* [Examples](#examples)\n* [Contributing](#contributing)\n* [Releasing](#releasing)\n* [License](#license)\n  \n## Motivation\nThe `getItemLayout` prop in a `SectionList` is an optimization prop that improves performance of the list by helping it to quickly calculate the size and position of its items.\n\nWhen you provide the `getItemLayout` prop, React Native can:\n\n* Jump directly to any list item without sequentially rendering all previous items.\n* Maintain scroll position accurately during layout changes or content updates.\n* Reduce the need for dynamic measurement as users scroll, leading to smoother experiences.\n* Access other props, such as `initialScrollIndex` and `scrollToLocation`\n\nThe `getItemLayout` prop is not trivial to implement for a `SectionList`. This library provides a simple way to create the `getItemLayout` prop for a `SectionList` with fixed or dynamic heights.\n\n## Installation\n\n```sh\nnpm install react-native-get-item-layout-section-list\n```\n\n## Usage\n\n### Basic\nThis example shows how to use the `getItemLayout` prop with fixed heights.\n\n```tsx\nimport getItemLayout from 'react-native-get-item-layout-section-list';\n\nconst ITEM_HEIGHT = 60;\nconst SECTION_HEADER_HEIGHT = 40;\n\nconst buildGetItemLayout = getItemLayout({\n  getItemHeight: ITEM_HEIGHT,\n  getSectionHeaderHeight: SECTION_HEADER_HEIGHT,\n});\n\n\u003cSectionList\n  getItemLayout={buildGetItemLayout} \n  keyExtractor={(item, index) =\u003e item + index} \n  renderItem={({item}) =\u003e (\n    \u003cView style={styles.item}\u003e\n      \u003cText style={styles.title}\u003e{item}\u003c/Text\u003e\n    \u003c/View\u003e\n  )} \n  renderSectionHeader={({section: {title}}) =\u003e (\n    \u003cText style={styles.header}\u003e{title}\u003c/Text\u003e\n  )} \n  sections={DATA}\n/\u003e\n```\n\n### Advanced\nThis example shows how to use the `getItemLayout` prop with dynamic heights.\n\n```tsx\nimport getItemLayout from 'react-native-get-item-layout-section-list';\n\nconst SECTION_HEADER_HEIGHT = 40;\n\nconst buildGetItemLayout = getItemLayout({\n  getItemHeight: (_item, sectionIndex, _itemIndex) =\u003e {\n    // Return a different height for even and odd items\n    return sectionIndex % 2 === 0 ? 60 : 40;\n  },\n  getSectionHeaderHeight: SECTION_HEADER_HEIGHT,\n});\n\n\u003cSectionList\n  getItemLayout={buildGetItemLayout}\n  keyExtractor={(item, index) =\u003e item + index}\n  renderItem={({item}) =\u003e (\n    \u003cView style={styles.item}\u003e\n      \u003cText style={styles.title}\u003e{item}\u003c/Text\u003e\n    \u003c/View\u003e\n  )}\n  renderSectionHeader={({section: {title}}) =\u003e (\n    \u003cText style={styles.header}\u003e{title}\u003c/Text\u003e\n  )}\n  sections={DATA}\n/\u003e\n````\n\n## Examples\nThere are fully functional examples in the `exmaple` directory.\n\nIf you'd like to actually run the examples, clone the repository and run the following commands:\n\n```sh\ncd example\nnpm install \u0026\u0026 pod install\nnpm run ios\n```\n\n## Contributing\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## Releasing\nSee the [releasing guide](RELEASING.md) to learn how to release new versions.\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamonbauer%2Freact-native-get-item-layout-section-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdamonbauer%2Freact-native-get-item-layout-section-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamonbauer%2Freact-native-get-item-layout-section-list/lists"}