{"id":24865358,"url":"https://github.com/frontendphil/react-undo-redo","last_synced_at":"2025-10-26T20:06:37.071Z","repository":{"id":37076802,"uuid":"302598564","full_name":"frontendphil/react-undo-redo","owner":"frontendphil","description":"A utility to add undo and redo functionality to any state managed through a reducer.","archived":false,"fork":false,"pushed_at":"2025-10-22T23:14:26.000Z","size":2200,"stargazers_count":28,"open_issues_count":8,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-23T01:12:00.433Z","etag":null,"topics":["hooks","hooks-api","react","state-management","undo-redo"],"latest_commit_sha":null,"homepage":"https://react-undo-redo.vercel.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frontendphil.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-10-09T09:45:47.000Z","updated_at":"2025-10-22T17:49:01.000Z","dependencies_parsed_at":"2023-12-20T11:53:38.015Z","dependency_job_id":"6236a91c-ab94-4bf9-8957-8c3f30678efd","html_url":"https://github.com/frontendphil/react-undo-redo","commit_stats":{"total_commits":247,"total_committers":3,"mean_commits":82.33333333333333,"dds":"0.27125506072874495","last_synced_commit":"64392cbfcaca52f3026e9f24f8165740b2337c01"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/frontendphil/react-undo-redo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frontendphil%2Freact-undo-redo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frontendphil%2Freact-undo-redo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frontendphil%2Freact-undo-redo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frontendphil%2Freact-undo-redo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frontendphil","download_url":"https://codeload.github.com/frontendphil/react-undo-redo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frontendphil%2Freact-undo-redo/sbom","scorecard":{"id":412142,"data":{"date":"2025-08-11","repo":{"name":"github.com/frontendphil/react-undo-redo","commit":"7c21a1220f5930bc4b23242744b2f157cdb9eefd"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.5,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":10,"reason":"25 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/tests.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/frontendphil/react-undo-redo/tests.yml/main?enable=pin","Info:   0 out of   1 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T22:59:19.320Z","repository_id":37076802,"created_at":"2025-08-18T22:59:19.320Z","updated_at":"2025-08-18T22:59:19.320Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280979467,"owners_count":26423964,"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-10-25T02:00:06.499Z","response_time":81,"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":["hooks","hooks-api","react","state-management","undo-redo"],"created_at":"2025-01-31T23:59:31.229Z","updated_at":"2025-10-26T20:06:37.038Z","avatar_url":"https://github.com/frontendphil.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-undo-redo\n\nA utility to add undo and redo functionality to any state managed through a reducer.\nThis library **does not** require [`redux`](https://redux.js.org/).\nIf you're looking for something that adds undo and redo to a state that is managed through `redux` you might be in the wrong place.\n\n## Installation\n\nThrough [`yarn`](https://yarnpkg.com/).\n\n```sh\nyarn add react-undo-redo\n```\n\nThrough [`npm`](https://www.npmjs.com/)\n\n```sh\nnpm install --save react-undo-redo\n```\n\n## Usage\n\nIn order to create the provider and hooks to manage undo and redo you call `createUndoRedo` and pass the `reducer` you'd like to enhance.\nThis method returns a provider component and hooks to work with your state.\nThe `reducer` you pass does not need any knowledge about this feature.\n\n```js\nimport { createUndoRedo } from \"react-undo-redo\"\n\nconst { UndoRedoProvider, usePast, usePresent, useFuture, useUndoRedo } =\n  createUndoRedo(reducer)\n```\n\n`createUndoRedo` also accepts an options object as a second parameter. Currently available options:\n\n- `track` - function with signature `(action) =\u003e boolean`. It is invoked on every dispatch and defines whether the new state is avaiable for undo/redo. If function returns `false`, the state won't affect the change history. It is useful in situations, when the change is not reflected in the UI or the user cannot control over.\n\n```js\nimport { createUndoRedo } from \"react-undo-redo\"\n\nconst { UndoRedoProvider, usePast, usePresent, useFuture, useUndoRedo } =\n  createUndoRedo(reducer, {track: (action) =\u003e action.type !== 'GET_NEW_TODOS'})\n```\n\n\n### `UndoRedoProvider`\n\n| Prop           | Required | Description                                                                                               |\n| -------------- | -------- | --------------------------------------------------------------------------------------------------------- |\n| `initialState` | ✔️       | The initial state that your reducer needs. This does **not** need any notion of past, present, or future. |\n| `past`         |          | If you like to restore a prior session you can pass an earlier version of past states here.               |\n| `future`       |          | If you like to restore a prior session you can pass an earlier version of future states here.             |\n\n```js\nfunction Component() {\n  return (\n    \u003cUndoRedoProvider initialState={0}\u003e\n      \u003cCounter /\u003e\n    \u003c/UndoRedoProvider\u003e\n  )\n}\n```\n\n### `usePresent` =\u003e `[state, dispatch]`\n\nThe return value of this hook mimics the [`useReducer`](https://reactjs.org/docs/hooks-reference.html#usereducer) hook.\nYou get access to the current present state.\nUse the `dispatch` method to dispatch any of your actions.\n\n```js\nfunction Component() {\n  const [count, dispatch] = usePresent()\n\n  return (\n    \u003c\u003e\n      \u003cdiv\u003ecount: {count}\u003c/div\u003e\n\n      \u003cbutton onClick={() =\u003e dispatch({ type: \"increment\" })}\u003eAdd 1\u003c/button\u003e\n    \u003c/\u003e\n  )\n}\n```\n\n### `useUndoRedo` =\u003e `[undo, redo]`\n\nReturns a tuple that contains methods to signal `undo` or `redo`.\nIf you call the two methods `react-undo-redo` updates the current `present` state.\n\n**Important**: You can also call `undo` or `redo` when there is nothing to undo or redo.\nHowever, you can check whether there is anything to undo or redo by checking the `isPossible` prop that is present on both methods.\n\n```js\nfunction Component() {\n  const [undo, redo] = useUndoRedo()\n\n  return (\n    \u003c\u003e\n      \u003cbutton disabled={!undo.isPossible} onClick={() =\u003e undo()}\u003e\n        Undo\n      \u003c/button\u003e\n\n      \u003cbutton disabled={!redo.isPossible} onClick={() =\u003e redo()}\u003e\n        Redo\n      \u003c/button\u003e\n    \u003c/\u003e\n  )\n}\n```\n\n### `usePast` =\u003e `[...state]`\n\nReturns all current past states (i.e. state snapshots when actions are dispatched).\nYou probably don't need to use this.\n\n### `useFuture` =\u003e `[...state]`\n\nReturns all current future states (i.e. states that have been undone).\nYou probably don't need to use this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrontendphil%2Freact-undo-redo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrontendphil%2Freact-undo-redo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrontendphil%2Freact-undo-redo/lists"}