{"id":20020129,"url":"https://github.com/wonism/use-flush","last_synced_at":"2026-05-12T10:33:59.719Z","repository":{"id":57388056,"uuid":"185639229","full_name":"wonism/use-flush","owner":"wonism","description":"React hooks for flushing frequent effect. It can optimize application via reducing re-rendering caused of effect","archived":false,"fork":false,"pushed_at":"2019-05-12T14:58:10.000Z","size":91,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T21:48:02.774Z","etag":null,"topics":["hooks","performance","react","reactjs"],"latest_commit_sha":null,"homepage":null,"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/wonism.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-08T16:03:54.000Z","updated_at":"2019-05-12T14:57:37.000Z","dependencies_parsed_at":"2022-09-11T07:12:21.319Z","dependency_job_id":null,"html_url":"https://github.com/wonism/use-flush","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fuse-flush","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fuse-flush/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fuse-flush/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fuse-flush/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wonism","download_url":"https://codeload.github.com/wonism/use-flush/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241454107,"owners_count":19965306,"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":["hooks","performance","react","reactjs"],"created_at":"2024-11-13T08:29:58.351Z","updated_at":"2026-05-12T10:33:59.692Z","avatar_url":"https://github.com/wonism.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Use Flush\n\u003e React hooks for flushing frequently changing state.\n\u003e It can optimize application via reducing re-rendering caused of changing state.\n\u003e (It has zero-dependencies!)\n\n[![npm version](https://badge.fury.io/js/use-flush.svg)](https://badge.fury.io/js/use-flush)\n[![Build Status](https://travis-ci.org/wonism/use-flush.svg)](https://travis-ci.org/wonism/use-flush)\n\n## Explanation\nLet's assume that the state will be changed very frequently like below.\n\n- `+` means every **n seconds**.\n- `*` means state is **changed**.\n\n```\n+--------+--------+--------+--------\n  * *   *  ** *** *  *    *\n```\n\nThe **flushed state** will be changed in every **n seconds** like below.\n\n```\n+--------+--------+--------+--------\n         *(3)     *(6)     *(2)\n```\n\n## Installation\n```\n$ npm i -S use-flush\n```\n\n## Usage\nIf you click 5 times in 2 seconds, `flushedCount` will be `[0, 1, 2, 3, 4]`.\n\n```js\nimport React, { useState } from 'react';\nimport { render } from 'react-dom';\nimport useFlush from 'use-flush';\n\nconst appRoot = document.getElementById('app');\n\nconst App = () =\u003e {\n  const [count, setCount] = useState(0);\n  const flushedCount = useFlush(count, 2000);\n\n  return (\n    \u003c\u003e\n      \u003cp\u003e\n        FLUSHED COUNT : {flushedCount.join(', ')}\n      \u003c/p\u003e\n      \u003cbutton onClick={() =\u003e { setCount(count + 1); }}\u003e\n        CLICK!\n      \u003c/button\u003e\n    \u003c/\u003e\n  );\n};\n\nrender(\n  \u003cApp /\u003e,\n  appRoot\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwonism%2Fuse-flush","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwonism%2Fuse-flush","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwonism%2Fuse-flush/lists"}