{"id":21076554,"url":"https://github.com/monojack/react-immer","last_synced_at":"2025-07-25T05:37:18.143Z","repository":{"id":33775385,"uuid":"158747196","full_name":"monojack/react-immer","owner":"monojack","description":"No nonsense state management with Immer and React hooks","archived":false,"fork":false,"pushed_at":"2023-01-03T15:22:59.000Z","size":1109,"stargazers_count":13,"open_issues_count":10,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-19T10:07:19.728Z","etag":null,"topics":["immer","react-hooks","reactjs","render-props","state-management"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/monojack.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}},"created_at":"2018-11-22T20:26:36.000Z","updated_at":"2023-03-14T23:10:00.000Z","dependencies_parsed_at":"2023-01-15T02:26:51.902Z","dependency_job_id":null,"html_url":"https://github.com/monojack/react-immer","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/monojack/react-immer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monojack%2Freact-immer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monojack%2Freact-immer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monojack%2Freact-immer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monojack%2Freact-immer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monojack","download_url":"https://codeload.github.com/monojack/react-immer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monojack%2Freact-immer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266962155,"owners_count":24012994,"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-07-25T02:00:09.625Z","response_time":70,"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":["immer","react-hooks","reactjs","render-props","state-management"],"created_at":"2024-11-19T19:29:03.745Z","updated_at":"2025-07-25T05:37:18.091Z","avatar_url":"https://github.com/monojack.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## react-immer\n\n[![Build Status](https://travis-ci.org/monojack/react-immer.svg?branch=master)](https://travis-ci.org/monojack/react-immer)\n[![npm version](https://img.shields.io/npm/v/react-immer.svg)](https://www.npmjs.com/package/react-immer)\n[![npm downloads](https://img.shields.io/npm/dm/react-immer.svg)](https://www.npmjs.com/package/react-immer)\n[![minified size](https://badgen.net/bundlephobia/min/react-immer)](https://bundlephobia.com/result?p=react-immer@latest)\n\nNo nonsense state management with [Immer](https://github.com/mweststrate/immer) and [React hooks](https://reactjs.org/docs/hooks-intro.html)\n\n**TL;DR**\n\n`index.js`\n\n```js\nimport React from 'react'\nimport ReactDOM from 'react'\n\nimport { createStore } from 'react-immer'\nimport Counter from './Counter'\n\ncreateStore({ count: 1 })\n\nfunction App() {\n  return \u003cCounter /\u003e\n}\n\nconst rootElement = document.getElementById('root')\nReactDOM.render(\u003cApp /\u003e, rootElement)\n```\n\n\u0026nbsp;\n\n`Counter.js`\n\n```js\n/* Counter.js */\n\nimport React from 'react'\nimport { useImmer } from 'react-immer'\n\nexport default function Counter() {\n  const [{ count }, produce] = useImmer({ count: state =\u003e state.count })\n\n  const decrement = draft =\u003e {\n    draft.count -= 1\n  }\n\n  const increment = draft =\u003e {\n    draft.count += 1\n  }\n\n  return (\n    \u003cdiv\u003e\n      \u003cbutton onClick={() =\u003e produce(decrement)}\u003e-\u003c/button\u003e\n      \u003cspan\u003e{count}\u003c/span\u003e\n      \u003cbutton onClick={() =\u003e produce(increment)}\u003e+\u003c/button\u003e\n    \u003c/div\u003e\n  )\n}\n```\n\n[![Edit react-immer-tldr](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/yq328o9rvx)\n\nWhat's cool about **react-immer** is that if you don't support [Hooks](https://reactjs.org/docs/hooks-intro.html) yet, you can use it inline and it will work like a [render prop](https://reactjs.org/docs/render-props.html). In this case, it takes two arguments, the _spec object_ and the _render function_.\n\n```js\nimport { useImmer } from 'react-immer'\n\n// ...\n// useImmer(specObj, renderFn)\n\u003cdiv\u003e\n  {useImmer({ count: state =\u003e state.count }, ({ count }, produce) =\u003e (\n    \u003cspan\u003e\n      \u003cbutton onClick={() =\u003e produce(decrement)}\u003e-\u003c/button\u003e\n      \u003cspan\u003e{count}\u003c/span\u003e\n      \u003cbutton onClick={() =\u003e produce(increment)}\u003e+\u003c/button\u003e\n    \u003c/span\u003e\n  ))}\n\u003c/div\u003e\n```\n\nOr, if you don't like the syntax, you can always use the **Immer** component\n\n```js\nimport { Immer } from 'react-immer'\n// ...\n\n\u003cImmer spec={{ count: state =\u003e state.count }}\u003e\n  {({ count }, produce) =\u003e (\n    \u003cspan\u003e\n      \u003cbutton onClick={() =\u003e produce(decrement)}\u003e-\u003c/button\u003e\n      \u003cspan\u003e{count}\u003c/span\u003e\n      \u003cbutton onClick={() =\u003e produce(increment)}\u003e+\u003c/button\u003e\n    \u003c/span\u003e\n  )}\n\u003c/Immer\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonojack%2Freact-immer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonojack%2Freact-immer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonojack%2Freact-immer/lists"}