{"id":15361952,"url":"https://github.com/tj/react-batch","last_synced_at":"2025-08-20T03:31:35.865Z","repository":{"id":65993696,"uuid":"91925765","full_name":"tj/react-batch","owner":"tj","description":"Batch component for performant frequent updates (flush on count or interval)","archived":false,"fork":false,"pushed_at":"2018-03-28T10:55:13.000Z","size":55,"stargazers_count":250,"open_issues_count":2,"forks_count":11,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-09T21:36:23.111Z","etag":null,"topics":["react","react-component"],"latest_commit_sha":null,"homepage":"","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/tj.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":"2017-05-21T01:18:34.000Z","updated_at":"2024-01-04T16:14:13.000Z","dependencies_parsed_at":"2023-05-21T17:45:10.617Z","dependency_job_id":null,"html_url":"https://github.com/tj/react-batch","commit_stats":{"total_commits":8,"total_committers":3,"mean_commits":"2.6666666666666665","dds":0.5,"last_synced_commit":"ee5baf1a659df8fc762f2fb3950c54aef35fbc99"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Freact-batch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Freact-batch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Freact-batch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Freact-batch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tj","download_url":"https://codeload.github.com/tj/react-batch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230388131,"owners_count":18217755,"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":["react","react-component"],"created_at":"2024-10-01T12:57:34.155Z","updated_at":"2024-12-19T06:09:52.199Z","avatar_url":"https://github.com/tj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Batch\n\nBatches and flushes renders based on the number of items available. Useful for large lists of frequently updated items which would otherwise cause performance problems with React's sync rendering.\n\n## Installation\n\n```\n$ yarn add tj/react-batch\n```\n\n## Properties\n\n- `count`: the number of items available for rendering __(required)__\n- `flushCount`: render after a given number of items __(required)__\n- `flushInterval`: render after a given interval is exceeded __(required)__\n- `render`: render callback __(required)__\n- `debug`: enable debug logging\n\n## Example\n\n```js\nclass BatchExample extends Component {\n  constructor() {\n    super()\n    this.list = this.list.bind(this)\n    this.state = { items: [] }\n    this.renders = 0\n  }\n\n  async componentDidMount() {\n    while (1) {\n      const prev = this.state.items\n      const items = [`Hello World #${prev.length}`, ...prev]\n      this.setState({ items })\n      await sleep(Math.random() * 30)\n    }\n  }\n\n  list() {\n    const { items } = this.state\n\n    return \u003cdiv\u003e\n      \u003cp\u003eCount: {items.length}\u003c/p\u003e\n      \u003cp\u003eRenders: {this.renders++}\u003c/p\u003e\n      \u003cul\u003e\n        {items.map((v, i) =\u003e \u003cli key={i}\u003e{v}\u003c/li\u003e)}\n      \u003c/ul\u003e\n    \u003c/div\u003e\n  }\n\n  render() {\n    return \u003cBatch\n      flushCount={10}\n      flushInterval={150}\n      count={this.state.items.length}\n      render={this.list}\n      debug /\u003e\n  }\n}\n```\n\n---\n\n![](https://img.shields.io/badge/license-MIT-blue.svg)\n![](https://img.shields.io/badge/status-stable-green.svg)\n\n\u003ca href=\"https://apex.sh\"\u003e\u003cimg src=\"http://tjholowaychuk.com:6000/svg/sponsor\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj%2Freact-batch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftj%2Freact-batch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj%2Freact-batch/lists"}