{"id":18338718,"url":"https://github.com/tableflip/react-data-dam","last_synced_at":"2025-06-13T02:04:00.641Z","repository":{"id":65483117,"uuid":"111664960","full_name":"tableflip/react-data-dam","owner":"tableflip","description":"🌊 Holds back your data until you're ready to see the updates.","archived":false,"fork":false,"pushed_at":"2018-02-06T15:55:48.000Z","size":232,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-11T21:22:39.311Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-data-dam","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/tableflip.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":"2017-11-22T09:42:43.000Z","updated_at":"2018-01-03T14:33:12.000Z","dependencies_parsed_at":"2023-01-25T11:15:21.613Z","dependency_job_id":null,"html_url":"https://github.com/tableflip/react-data-dam","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/tableflip/react-data-dam","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflip%2Freact-data-dam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflip%2Freact-data-dam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflip%2Freact-data-dam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflip%2Freact-data-dam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tableflip","download_url":"https://codeload.github.com/tableflip/react-data-dam/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflip%2Freact-data-dam/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259520035,"owners_count":22870384,"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-11-05T20:14:56.614Z","updated_at":"2025-06-13T02:04:00.621Z","avatar_url":"https://github.com/tableflip.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://user-images.githubusercontent.com/152863/33171665-06ce78d6-d045-11e7-8dd7-80fecd7a9ad1.png\" width=\"150\" /\u003e\n\n# react-data-dam\n\n[![Build Status](https://travis-ci.org/tableflip/react-data-dam.svg?branch=master)](https://travis-ci.org/tableflip/react-data-dam) [![dependencies Status](https://david-dm.org/tableflip/react-data-dam/status.svg)](https://david-dm.org/tableflip/react-data-dam) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n\u003e Holds back your data until you're ready to see the updates. Useful for implementing a Twitter style \"See n new Tweets\" button.\n\nInitial data passed to `DataDam` will be passed onto it's children, but changes to that data are held back until the children signal that they want to receive it. Children are passed a diff object which describes the difference between the data they currently have and what is being held back so they know what they're missing.\n\n## Install\n\n```sh\nnpm install react-data-dam\n```\n\n## Usage\n\n```js\nimport React from 'react'\nimport { DataDam } from 'react-data-dam'\n\nexport default ({ items }) =\u003e (\n  \u003cDataDam data={items}\u003e\n    {(data, diff, release) =\u003e (\n      \u003cdiv\u003e\n        \u003cul\u003e\n          {data.map((d) =\u003e \u003cli\u003e{d._id}\u003c/li\u003e)}\n        \u003c/ul\u003e\n        {diff.total.changes ? (\n          \u003cbutton onClick={release}\u003eLoad {diff.total.changes} updates\u003c/button\u003e\n        ) : null}\n      \u003c/div\u003e\n    )}\n  \u003c/DataDam\u003e\n)\n```\n\n## API\n\n### `\u003cDataDam /\u003e`\n\n#### `data`\n\nType: `PropTypes.arrayOf(PropTypes.object).isRequired`\n\nThe data you want to build a dam against. Only the initial value will be passed through to child components until [`release`](#children) is called.\n\nThe [`flowing`](#flowing) prop can be used to allow data through from initial mount to a time that you're ready to enforce the dam.\n\nObjects in the array should have an `_id` property to determine updates. This can be changed using the [`idProp`](#idprop) prop.\n\n#### `children`\n\nType: `PropTypes.func.isRequired`\n\nA function that renders the children. It is passed 3 parameters:\n\n* `data` - the cached data since the last release or initial mount\n* `diff` - the difference between the passed data and the data that is being held back\n* `release` - a function to call that will release any data that is held back\n\nThe diff object looks like this:\n\n```js\n{\n  added: [], // items that were added to data\n  removed: [], // items that were removed from data\n  updated: [],  // items that remained in data but were altered in some way\n  moved: [], // items that changed index\n  total: {\n    changes: 0, // added + removed + updated\n    added: 0,\n    removed: 0,\n    updated: 0,\n    moved: 0\n  }\n}\n```\n\n#### `flowing`\n\nType: `PropTypes.bool`, default: `false`\n\nAllow data to flow freely through the dam without needing to call release.\n\n#### `idProp`\n\nType: `PropTypes.string`, default: `_id`\n\nChanges the property that is considered to be the ID of the data items.\n\n#### `autoRelease`\n\nType: `PropTypes.func`\n\nCalled each time the held back data changes. When this function returns `true` the held back data will be released. It is passed 4 parameters:\n\n* `data` - the cached data since the last release or initial mount\n* `diff` - the difference between the passed data and the data that is being held back\n* `nextData` - the data that is being held back\n* `incrementalDifference` - a function you can call to calculate the incremental diff, which is the difference between the previous `nextData` and the new `nextData`\n\n## Contribute\n\nFeel free to dive in! [Open an issue](https://github.com/tableflip/react-data-dam/issues/new) or submit PRs.\n\n## License\n\n[MIT](LICENSE) © Alan Shaw\n\n---\n\nA [(╯°□°）╯︵TABLEFLIP](https://tableflip.io) side project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftableflip%2Freact-data-dam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftableflip%2Freact-data-dam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftableflip%2Freact-data-dam/lists"}