{"id":15844199,"url":"https://github.com/afeiship/use-active-state","last_synced_at":"2026-04-18T07:36:53.791Z","repository":{"id":96088413,"uuid":"54450356","full_name":"afeiship/use-active-state","owner":"afeiship","description":"React hook for active state.","archived":false,"fork":false,"pushed_at":"2021-09-07T05:28:57.000Z","size":4693,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-30T22:33:46.497Z","etag":null,"topics":["active","component","hook","rc","react","state"],"latest_commit_sha":null,"homepage":"","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/afeiship.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2016-03-22T06:18:22.000Z","updated_at":"2021-09-07T05:29:00.000Z","dependencies_parsed_at":"2023-04-21T00:56:43.221Z","dependency_job_id":null,"html_url":"https://github.com/afeiship/use-active-state","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/afeiship/use-active-state","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fuse-active-state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fuse-active-state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fuse-active-state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fuse-active-state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afeiship","download_url":"https://codeload.github.com/afeiship/use-active-state/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afeiship%2Fuse-active-state/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31961347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"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":["active","component","hook","rc","react","state"],"created_at":"2024-10-05T17:20:45.335Z","updated_at":"2026-04-18T07:36:53.752Z","avatar_url":"https://github.com/afeiship.png","language":"TypeScript","readme":"# use-active-state\n\u003e React hook for active state.\n\n[![version][version-image]][version-url]\n[![license][license-image]][license-url]\n[![size][size-image]][size-url]\n[![download][download-image]][download-url]\n\n## installation\n```shell\nnpm install -S @jswork/use-active-state\n```\n\n## usage\n  ```tsx\n  import React from 'react';\n  import useActiveState from '@jswork/use-active-state';\n  import styled from 'styled-components';\n\n  const Container = styled.div`\n    width: 40%;\n    min-width: 400px;\n    margin: 30px auto 0;\n    padding: 50px;\n    border: 1px solid #ccc;\n    .row {\n      display: flex;\n      margin-bottom: 10px;\n      strong {\n        display: inline-block;\n        width: 120px;\n      }\n    }\n\n    .result {\n      background: #eee;\n      padding: 20px;\n      border: 1px dashed #f60;\n      margin-top: 10px;\n    }\n  `;\n\n  export default (props: any) =\u003e {\n    const { state, sync, get, $ } = useActiveState(() =\u003e {\n      console.log('state:', state, get('username'));\n    });\n\n    console.log('state:', state);\n\n    return (\n      \u003cContainer\u003e\n        \u003cform autoComplete=\"off\"\u003e\n          \u003clabel className=\"row\"\u003e\n            \u003cstrong\u003eusername:\u003c/strong\u003e\n            \u003cinput type=\"text\" name=\"username\" onChange={sync()} /\u003e\n          \u003c/label\u003e\n          \u003clabel className=\"row\"\u003e\n            \u003cstrong\u003eemail:\u003c/strong\u003e\n            \u003cinput type=\"text\" name=\"email\" onChange={sync()} /\u003e\n          \u003c/label\u003e\n          \u003clabel className=\"row\"\u003e\n            \u003cstrong\u003epassword:\u003c/strong\u003e\n            \u003cinput type=\"password\" name=\"password\" onChange={sync()} /\u003e\n          \u003c/label\u003e\n          \u003cdiv className=\"actions\"\u003e\n            \u003cbutton type=\"button\"\u003eSubmit\u003c/button\u003e\n            \u003cbutton type=\"button\" onClick={e =\u003e {\n              $.reset();\n            }}\u003ereset\u003c/button\u003e\n          \u003c/div\u003e\n        \u003c/form\u003e\n\n        \u003cdiv className=\"result\"\u003e\n          \u003cpre\u003e\n            \u003ccode\u003e{JSON.stringify(state, null, 2)}\u003c/code\u003e\n          \u003c/pre\u003e\n        \u003c/div\u003e\n        \u003cdiv className=\"result\"\u003e\n          \u003cpre\u003e\n            \u003ccode\u003eisTouched: {String($.touched())}\u003c/code\u003e\n          \u003c/pre\u003e\n        \u003c/div\u003e\n      \u003c/Container\u003e\n    );\n  };\n  ```\n\n## preview\n- https://afeiship.github.io/use-active-state/\n\n## license\nCode released under [the MIT license](https://github.com/afeiship/use-active-state/blob/master/LICENSE.txt).\n\n[version-image]: https://img.shields.io/npm/v/@jswork/use-active-state\n[version-url]: https://npmjs.org/package/@jswork/use-active-state\n\n[license-image]: https://img.shields.io/npm/l/@jswork/use-active-state\n[license-url]: https://github.com/afeiship/use-active-state/blob/master/LICENSE.txt\n\n[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/use-active-state\n[size-url]: https://github.com/afeiship/use-active-state/blob/master/dist/use-active-state.min.js\n\n[download-image]: https://img.shields.io/npm/dm/@jswork/use-active-state\n[download-url]: https://www.npmjs.com/package/@jswork/use-active-state\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafeiship%2Fuse-active-state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafeiship%2Fuse-active-state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafeiship%2Fuse-active-state/lists"}