{"id":19922961,"url":"https://github.com/majidux/usestates","last_synced_at":"2025-05-03T07:30:57.221Z","repository":{"id":57388413,"uuid":"278582025","full_name":"majidux/useStates","owner":"majidux","description":"A custom hook for having multiple states. This package can only use in Reactjs.","archived":false,"fork":false,"pushed_at":"2021-06-29T09:39:05.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-20T17:48:15.520Z","etag":null,"topics":["hooks","react","react-hooks","react-native","reactjs","strategy-design-pattern"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/majidux.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}},"created_at":"2020-07-10T08:34:43.000Z","updated_at":"2022-01-03T05:46:07.000Z","dependencies_parsed_at":"2022-09-11T20:00:13.624Z","dependency_job_id":null,"html_url":"https://github.com/majidux/useStates","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majidux%2FuseStates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majidux%2FuseStates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majidux%2FuseStates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majidux%2FuseStates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/majidux","download_url":"https://codeload.github.com/majidux/useStates/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252156810,"owners_count":21703356,"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","react","react-hooks","react-native","reactjs","strategy-design-pattern"],"created_at":"2024-11-12T22:12:38.442Z","updated_at":"2025-05-03T07:30:56.957Z","avatar_url":"https://github.com/majidux.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# useStates\n\nA custom hook based on useReducer and inspired by strategy design pattern for having multiple states\n\n\n###### With npm:\n```javascript\nnpm install --save use-states-react\n```\n\n###### With yarn:\n```javascript\nyarn add use-states-react\n```\n\n\nThis is how you are going to use it : =\u003e\n```javascript\nimport { useStates } from \"use-states-react\";\n\nconst initialState = {\n  name: \"\",\n};\n\nconst Example = () =\u003e {\n  const [state, setState] = useStates\u003cany\u003e(initialState);\n  const { name } = state;\n  const onChange = ({ target: { name, value } }) =\u003e {\n    setState(\n      {\n        [name]: value,\n      },\n      () =\u003e console.log(\"Callback function\")\n    );\n  };\n  return (\n    \u003c\u003e\n      \u003cinput name=\"name\" type=\"text\" value={name} onChange={onChange} /\u003e\n    \u003c/\u003e\n  );\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmajidux%2Fusestates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmajidux%2Fusestates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmajidux%2Fusestates/lists"}