immer README

The project's README from github.com/immerjs/immer. As one markdown file: README.md.

Immer

npm Build Status Coverage Status code style: prettier OpenCollective OpenCollective Gitpod Ready-to-Code

Create the next immutable state tree by simply modifying the current tree

Winner of the "Breakthrough of the year" React open source award and "Most impactful contribution" JavaScript open source award in 2019

Contribute using one-click online setup

You can use Gitpod (a free online VSCode like IDE) for contributing online. With a single click it will launch a workspace and automatically:

so that you can start coding straight away.

Open in Gitpod

Documentation

The documentation of this package is hosted at https://immerjs.github.io/immer/

Support

Did Immer make a difference to your project? Join the open collective at https://opencollective.com/immer!

Release notes

https://github.com/immerjs/immer/releases

immer (immerjs/immer)

Searching Database…

29K ·GitHub
这是做什么用的?Immer 是一个小巧的 JavaScript 库,用于处理不可变状态:你写的代码就像直接修改当前状态一样,它会帮你生成下一个不可变的状态树。
它是我要引入的框架,还是在代码里调用的库?只是一个普通的库——一个 npm 包,运行时零依赖,你在自己的 JavaScript 代码里调用它即可,不是规定你应用结构的框架。
怎么把它加到项目里?从 npm 安装——npm install immer(或 yarn add immer)——然后像其他包一样导入就行;完整文档在 immerjs.github.io/immer 上。
除了它,我还需要装别的东西吗?不需要。这个包运行时零依赖,只要你的 JavaScript 环境里有 npm 或 yarn 就够了。
它只能配合 React 用,还是什么都能用?它是纯 JavaScript,什么场景都能用,不过在 React 圈子里最有名——曾获 2019 年 React 开源大奖——也常用于 Redux 风格的 reducer。
它只能在 Node 里跑,浏览器里也行吗?它是纯 JavaScript,没有任何原生组件,所以 JavaScript 能跑的地方它都能跑——浏览器里的网页应用可以,服务器上的 Node 也可以。
用 Immer 写出来的代码实际上长什么样?你把当前状态和一个修改草稿副本的函数交给它;Immer 会追踪你改动了哪些地方,并返回一个全新的不可变状态,这样就不用手动展开和复制对象了。
它提供 Flow 或 TypeScript 的类型定义吗?仓库维护了 Flow 类型定义——它的测试脚本会对 __tests__/flow 目录运行 yarn flow check——所以 API 对 Flow 用户是有类型的。
我不想在本地搭建开发环境,能直接参与开发吗?可以。README 提供了一键打开的 Gitpod 工作区:它会克隆仓库、安装依赖并运行 'yarn run start',你可以直接在浏览器里开始写代码。
这个项目还活跃吗?活跃——它没有被归档,有自动发布的 CI(release.yml)以及测试和文档工作流,从 2017 年就开始开发,README 里还有版本发布说明部分。
What are similar projects?normalizr, Recoil, zustand, nuqs, redux-form, reactstrap, reselect, redux
Creator
immerjs
Size
7.4 MB
Stars
29K
Age
8y
Commits · 90 Days