{"id":20022241,"url":"https://github.com/lucifier129/create-react-store","last_synced_at":"2025-05-05T01:31:26.216Z","repository":{"id":77717966,"uuid":"224333013","full_name":"Lucifier129/create-react-store","owner":"Lucifier129","description":"Create reactive stores for React App","archived":false,"fork":false,"pushed_at":"2019-11-28T09:31:10.000Z","size":9,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T14:52:28.850Z","etag":null,"topics":["react","react-hooks","state-management"],"latest_commit_sha":null,"homepage":"https://lucifier129.github.io/create-react-store-todo-app/build/","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/Lucifier129.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}},"created_at":"2019-11-27T03:07:04.000Z","updated_at":"2023-03-07T14:58:14.000Z","dependencies_parsed_at":"2023-05-23T21:00:43.152Z","dependency_job_id":null,"html_url":"https://github.com/Lucifier129/create-react-store","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.25,"last_synced_commit":"b79e352b89a281ac772ff3cd80c6bd6b108e65c1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucifier129%2Fcreate-react-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucifier129%2Fcreate-react-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucifier129%2Fcreate-react-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lucifier129%2Fcreate-react-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lucifier129","download_url":"https://codeload.github.com/Lucifier129/create-react-store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252423148,"owners_count":21745551,"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":["react","react-hooks","state-management"],"created_at":"2024-11-13T08:39:40.219Z","updated_at":"2025-05-05T01:31:26.209Z","avatar_url":"https://github.com/Lucifier129.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# create-react-store\n\nCreate a reactive store for React App\n\nMake developing React App easier and happier!\n\nDemo: [create-react-store-todo-app](https://github.com/Lucifier129/create-react-store-todo-app)\n\n## Installation\n\n```shell\nnpm install --save create-react-store\n```\n\n## Usage\n\n```javascript\nimport {\n  isReactive,\n  useAction,\n  createStore,\n  useReactive,\n  useComputed,\n  useBinding,\n  CreateStoreOptions,\n  Store,\n  mutate,\n  remove,\n  Provider,\n  enableTracing,\n  disableTracing\n} from 'create-react-store'\n```\n\ncreate-react-store uses `bistate`, See [bistate docs](https://github.com/Lucifier129/bistate#caveats) for more information\n\n```javascript\nimport { createStore, useAction } from 'create-react-store'\n\n// pass initialData\nconst store = createStore([])\n\nconst App: React.FC = () =\u003e {\n  // read data from store.useData()\n  let todos = store.useData()\n\n  let handleAddTodo = useAction(text =\u003e {\n    // mutate data inside action\n    todos.push({\n      id: Math.random(),\n      text\n    })\n  })\n\n  return (\n    \u003c\u003e\n      \u003cTodoHeader onAdd={handleAddTodo} /\u003e\n      {todos.map(todo =\u003e (\n        \u003cTodoItem key={todo.id} todo={todo} /\u003e\n      ))}\n    \u003c/\u003e\n  )\n}\n\nReactDOM.render(\n  \u003cProvider stores={[store]}\u003e\n    \u003cApp /\u003e\n  \u003c/Provider\u003e,\n  container\n)\n```\n\n## API\n\n### createStore(initialData) -\u003e { useData, useCreate, Provider }\n\ncreateStore receives object as initialState, return { useData, useCreate, Provider }\n\n- useData() -\u003e data\n  - a react-hooks use in function-component to read store data\n- useCreate(data) -\u003e store\n  - a react-hooks use in function-component to re-create a store with data\n- Provider({ initialData: object}) \n  - Provider is a React Component to provide data for sub-components\n\n### Provider({ stores: Store[] })\n\na React Component recieves stores to provide data for sub-components.\n\n### useAction(f) -\u003e f\n\nuseAction is a react-hooks use in function-component, it will return a wrapped function has the same type sinature\n\nIt's safely to mutate objects in useAction(f), `bistate` will take care the immutable and re-render component\n\n### useReactive(object) -\u003e object\n\nuseReactive is a react-hooks use in function-component, it will return a reactive one has the same structure/data\n\nThe data returned by useReactive, can be mutated via useAction\n\n### isReactive(object) -\u003e boolean\n\ncheck whether object is reactive or not\n\n### enableTracing()\n\nenable tracing actions and show logs in console\n\n### disableTracing()\n\ndisable tracing actions\n\n### [useComputed](https://github.com/Lucifier129/bistate#usecomputedobj-deps---obj)\n\n### [useBinding](https://github.com/Lucifier129/bistate#usebindingbistate---obj)\n\n### [remove](https://github.com/Lucifier129/bistate#removebistate---void)\n\n### [mutate](https://github.com/Lucifier129/bistate#mutatef---value_returned_by_f)\n\n## PR is Welcome:)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucifier129%2Fcreate-react-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucifier129%2Fcreate-react-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucifier129%2Fcreate-react-store/lists"}