{"id":4240,"url":"https://github.com/expo/react-native-scrollable-decorator","last_synced_at":"2025-04-15T02:50:46.681Z","repository":{"id":34811612,"uuid":"38797865","full_name":"expo/react-native-scrollable-decorator","owner":"expo","description":"A standard interface for your scrollable React Native components, making it easier to compose components.","archived":false,"fork":false,"pushed_at":"2015-12-18T19:16:07.000Z","size":5,"stargazers_count":37,"open_issues_count":1,"forks_count":2,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-08T12:09:44.367Z","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/expo.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":"2015-07-09T04:52:32.000Z","updated_at":"2024-03-02T02:57:46.000Z","dependencies_parsed_at":"2022-08-17T22:50:43.342Z","dependency_job_id":null,"html_url":"https://github.com/expo/react-native-scrollable-decorator","commit_stats":null,"previous_names":["exponentjs/react-native-scrollable-decorator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expo%2Freact-native-scrollable-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expo%2Freact-native-scrollable-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expo%2Freact-native-scrollable-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/expo%2Freact-native-scrollable-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/expo","download_url":"https://codeload.github.com/expo/react-native-scrollable-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997087,"owners_count":21195797,"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-01-05T20:17:05.522Z","updated_at":"2025-04-15T02:50:46.664Z","avatar_url":"https://github.com/expo.png","language":"JavaScript","funding_links":[],"categories":["Components"],"sub_categories":["UI"],"readme":"# react-native-scrollable-decorator [![Slack](http://slack.exponentjs.com/badge.svg)](http://slack.exponentjs.com)\n\nThe `@scrollable` decorator lets your scrollable React Native components conform to a standard interface, making it easier to compose components. This lets you compose different types of ScrollView-like components while preserving the `ScrollView` API, including methods like `scrollTo`.\n\nSee [ScrollableMixin](https://github.com/exponentjs/react-native-scrollable-mixin) for the mixin version of this decorator.\n\n[![npm package](https://nodei.co/npm/react-native-scrollable-decorator.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/react-native-scrollable-decorator/)\n\n## Installation\n```\nnpm install react-native-scrollable-decorator\n```\n\n## Usage\n\nDecorate your scrollable React components with `@scrollable` and implement `getScrollResponder()`, which must return the underlying scrollable component's scroll responder.\n\n```js\nlet scrollable = require('react-native-scrollable-decorator');\n\n@scrollable\nclass InfiniteScrollView extends React.Component {\n\n  static propTypes = {\n    ...ScrollView.propTypes,\n    renderScrollComponent: React.PropTypes.func.isRequired,\n  };\n\n  /**\n   * IMPORTANT: You must return the scroll responder of the underlying\n   * scrollable component from getScrollResponder() when using @scrollable.\n   */\n  getScrollResponder() {\n    return this._scrollView.getScrollResponder();\n  },\n\n  setNativeProps(nativeProps) {\n    this._scrollView.setNativeProps(nativeProps);\n  },\n\n  render() {\n    var {\n      renderScrollComponent,\n      ...props\n    } = this.props;\n    return React.cloneElement(renderScrollComponent(props), {\n      ref: component =\u003e {\n        this._scrollView = component;\n      },\n    });\n  },\n});\n```\n\n## Features\n\nBy decorating your custom component with `@scrollable`, your component gets the `ScrollView` API. For example:\n\n```js\nclass App extends React.Component {\n  render() {\n    return (\n      \u003cListView\n        ref={component =\u003e { this._scrollView = component; }}\n        renderScrollComponent={props =\u003e \u003cInfiniteScrollView {...props} /\u003e}\n        dataSource={...}\n        renderRow={...}\n      /\u003e\n    );\n  }\n\n  _scrollToTop() {\n    // By having all scrollable components conform to the scrollable standard,\n    // calling `scrollTo` on your top-level scrollable component will\n    // successfully scroll the underlying scroll view.\n    this._scrollView.scrollTo(0, 0);\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpo%2Freact-native-scrollable-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexpo%2Freact-native-scrollable-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpo%2Freact-native-scrollable-decorator/lists"}