readme.md
This file
Path
readme.md
367 lines · 14.6 KiB · Markdown
Last changed by
Simpler donate linkMichel Weststratebefore adoption782bf82
History of this fileTake it
Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 1–2why, one step back1# Immer2Readme cleanupMichel Weststratebefore adoptiona3b49ff
line 3why, one step back3[](https://travis-ci.org/mweststrate/immer)Merge pull request #25 from Gregjarvez/travisMichel Weststratebefore adoption55ec6d0
line 4why, one step back4[](https://coveralls.io/github/mweststrate/immer?branch=master)Readme cleanupMichel Weststratebefore adoptiona3b49ff
line 5why, one step back5[](https://github.com/prettier/prettier)Simpler donate linkMichel Weststratebefore adoption782bf82
line 6why, one step back6[](https://www.paypal.me/michelweststrate)Merge pull request #25 from Gregjarvez/travisMichel Weststratebefore adoption55ec6d0
line 7why, one step back7Updated changelogMichel Weststratebefore adoption8f44348
line 8why, one step back8_Create the next immutable state tree by simply modifying the current tree_Doc improvementsMichel Weststratebefore adoptiona3fcf04
lines 9–11why, one step back910---11Readme cleanupMichel Weststratebefore adoptiona3b49ff
line 12why, one step back12* NPM / Yarn: `npm install immer`Merge pull request #68 from mweststrate/feature/reuseMichel Weststratebefore adoption20394c0
line 13why, one step back13* CDN: https://unpkg.com/immer/dist/immer.umd.js. Exposed global is `immer`.Merge pull request #39 from fkhadra/issue-7-add-badges-and-cdnMichel Weststratebefore adoption227e953
line 14why, one step back14Updated readme linksMichel Weststratebefore adoption553b6ce
lines 15–16why, one step back15---16Object.is for equality, more tests. Fixes #43, #42, #48Michel Weststratebefore adoptione29a792
line 17why, one step back17* Egghead lesson covering all of immer (7m): [Simplify creating immutable data trees with Immer](https://egghead.io/lessons/redux-simplify-creating-immutable-data-trees-with-immer)Updated readme linksMichel Weststratebefore adoption553b6ce
lines 18–19why, one step back18* Introduction blogpost: [Immer: Immutability the easy way](https://medium.com/@mweststrate/introducing-immer-immutability-the-easy-way-9d73d8f71cb3)19Fixed typo and yarn.lockMichel Weststratebefore adoption101aac2
line 20why, one step back20Immer (German for: always) is a tiny package that allows you to work with immutable state in a more convenient way.Readme improvementsMichel Weststratebefore adoption58e9b57
line 21why, one step back21It is based on the [_copy-on-write_](https://en.wikipedia.org/wiki/Copy-on-write) mechanism.Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
line 22why, one step back22Readme improvementsMichel Weststratebefore adoption58e9b57
line 23why, one step back23The basic idea is that you will apply all your changes to a temporarily _draftState_, which is a proxy of the _currentState_.`immer` -> `produce`. Implements #24Michel Weststratebefore adoptione3eacea
line 24why, one step back24Once all your mutations are completed, Immer will produce the _nextState_ based on the mutations to the draft state.Readme improvementsMichel Weststratebefore adoption58e9b57
line 25why, one step back25This means that you can interact with your data by simply modifying it, while keeping all the benefits of immutable data.Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
line 26why, one step back26Merge pull request #56 from jkhedani/masterMichel Weststratebefore adoption076fbd6
line 27why, one step back27Doc improvementsMichel Weststratebefore adoptiona3fcf04
line 28why, one step back28`immer` -> `produce`. Implements #24Michel Weststratebefore adoptione3eacea
line 29why, one step back29Using Immer is like having a personal assistant; he takes a letter (the current state), and gives you a copy (draft) to jot changes onto. Once you are done, the assistant will take your draft and produce the real immutable, final letter for you (the next state).Readme improvementsMichel Weststratebefore adoption58e9b57
line 30why, one step back30Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 31why, one step back31A mindful reader might notice that this is quite similar to `withMutations` of ImmutableJS. It is indeed, but generalized and applied to plain, native JavaScript data structures (arrays and objects) without further needing any library.Doc improvementsMichel Weststratebefore adoptiona3fcf04
lines 32–34why, one step back3233## API34Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 35why, one step back35The Immer package exposes a default function that does all the work.Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
line 36why, one step back36`immer` -> `produce`. Implements #24Michel Weststratebefore adoptione3eacea
line 37why, one step back37`produce(currentState, producer: (draftState) => void): nextState`Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
line 38why, one step back38Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 39–40why, one step back39There is also a curried overload that is explained [below](#currying)40Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 41–43why, one step back41## Example4243```javascript`immer` -> `produce`. Implements #24Michel Weststratebefore adoptione3eacea
line 44why, one step back44import produce from "immer"Merge pull request #22 from mweststrate/feature/es5Michel Weststratebefore adoption4165abb
line 45why, one step back45Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 46–51why, one step back46const baseState = [47 {48 todo: "Learn typescript",49 done: true50 },51 {Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 52why, one step back52 todo: "Try immer",Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 53–56why, one step back53 done: false54 }55]56`immer` -> `produce`. Implements #24Michel Weststratebefore adoptione3eacea
line 57why, one step back57const nextState = produce(baseState, draftState => {Doc improvementsMichel Weststratebefore adoptiona3fcf04
lines 58–59why, one step back58 draftState.push({ todo: "Tweet about it" })59 draftState[1].done = trueFixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 60–62why, one step back60})61```62Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 63why, one step back63The interesting thing about Immer is that the `baseState` will be untouched, but the `nextState` will reflect all changes made to `draftState`.Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 64–79why, one step back6465```javascript66// the new item is only added to the next state,67// base state is unmodified68expect(baseState.length).toBe(2)69expect(nextState.length).toBe(3)7071// same for the changed 'done' prop72expect(baseState[1].done).toBe(false)73expect(nextState[1].done).toBe(true)7475// unchanged data is structurally shared76expect(nextState[0]).toBe(baseState[0])77// changed data not (dûh)78expect(nextState[1]).not.toBe(baseState[1])79```Doc improvementsMichel Weststratebefore adoptiona3fcf04
lines 80–82why, one step back8081## Benefits82Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 83–88why, one step back83* Immutability with normal JavaScript objects and arrays. No new APIs to learn!84* Strongly typed, no string based paths selectors etc.85* Structural sharing out of the box86* Object freezing out of the box87* Deep updates are a breeze88* Boilerplate reduction. Less noise, more concise code.Merge pull request #68 from mweststrate/feature/reuseMichel Weststratebefore adoption20394c0
line 89why, one step back89* Small: bundled and minified: 2KB.Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
line 90why, one step back90Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 91why, one step back91Read further to see all these benefits explained.Merge pull request #15 from mweststrate/feature/freezeMichel Weststratebefore adoption0d24494
line 92why, one step back92Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 93–94why, one step back93## Reducer Example94Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 95why, one step back95Here is a simple example of the difference that Immer could make in practice.Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 96–97why, one step back9697```javascriptMerge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 98–100why, one step back98// Redux reducer99// Shortened, based on: https://github.com/reactjs/redux/blob/master/examples/shopping-cart/src/reducers/products.js100const byId = (state, action) => {Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
line 101why, one step back101 switch (action.type) {Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 102why, one step back102 case RECEIVE_PRODUCTS:Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 103–104why, one step back103 return {104 ...state,Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 105–108why, one step back105 ...action.products.reduce((obj, product) => {106 obj[product.id] = product107 return obj108 }, {})Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 109–115why, one step back109 }110 default:111 return state112 }113}114```115Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 116why, one step back116After using Immer, that simply becomes:Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 117–118why, one step back117118```javascript`immer` -> `produce`. Implements #24Michel Weststratebefore adoptione3eacea
line 119why, one step back119import produce from 'immer'Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
line 120why, one step back120Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 121–122why, one step back121const byId = (state, action) =>122 produce(state, draft => {Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
line 123why, one step back123 switch (action.type) {Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 124–126why, one step back124 case RECEIVE_PRODUCTS:125 action.products.forEach(product => {126 draft[product.id] = productFixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
lines 127–131why, one step back127 })128 }129 })130```131transpile es5 codeMichel Weststratebefore adoptionf012154
line 132why, one step back132Notice that it is not needed to handle the default case, a producer that doesn't do anything will simply return the original state.Fixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
line 133why, one step back133transpile es5 codeMichel Weststratebefore adoptionf012154
line 134why, one step back134Creating Redux reducer is just a sample application of the Immer package.Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 135why, one step back135Immer is not just designed to simplify Redux reducers.transpile es5 codeMichel Weststratebefore adoptionf012154
lines 136–138why, one step back136It can be used in any context where you have an immutable data tree that you want to clone and modify (with structural sharing).137138_Note: it might be tempting after using producers a while, to just put `produce` in your root reducer, and then past the draft along to each reducer and work on that. Don't do that. It kills the point of Redux where each reducer is testable as pure reducer. Immer is best used when applying it to small individual pieces of logic._Added examples from the Redux Update Patterns PageMichel Weststratebefore adoptionda3a08b
line 139why, one step back139Added `React.setState` exampleMichel Weststratebefore adoption2c8a71a
lines 140–149why, one step back140## React.setState example141142Deep updates in the state of React components can be greatly simplified as well by using immer.143Take for example the following onClick handlers (Try in [codesandbox](https://codesandbox.io/s/m4yp57632j)):144145```javascript146/**147 * Classic React.setState with a deep merge148 */149onBirthDayClick1 = () => {Merge pull request #104 from mikollo/patch-1Michel Weststratebefore adoptionc047a59
line 150why, one step back150 this.setState((prevState)=>({Added `React.setState` exampleMichel Weststratebefore adoption2c8a71a
line 151why, one step back151 user: {Merge pull request #104 from mikollo/patch-1Michel Weststratebefore adoptionc047a59
lines 152–153why, one step back152 ...prevState.user,153 age: prevState.user.age + 1Added `React.setState` exampleMichel Weststratebefore adoption2c8a71a
line 154why, one step back154 }Merge pull request #104 from mikollo/patch-1Michel Weststratebefore adoptionc047a59
line 155why, one step back155 }))Added `React.setState` exampleMichel Weststratebefore adoption2c8a71a
lines 156–159why, one step back156}157158/**159 * ...But, since setState accepts functions,Implemented and document #108: allow returning values from producersMichel Weststratebefore adoptionc589ddd
line 160why, one step back160 * we can just create a curried producer and further simplify!Added `React.setState` exampleMichel Weststratebefore adoption2c8a71a
lines 161–164why, one step back161*/162onBirthDayClick2 = () => {163 this.setState(produce(draft => {164 draft.user.age += 1Merge pull request #106 from asamiller/patch-1benbraoubefore adoption5281004
line 165why, one step back165 }))Added `React.setState` exampleMichel Weststratebefore adoption2c8a71a
lines 166–168why, one step back166}167```168Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 169–171why, one step back169## Currying170171`produce` can be called with one or two arguments.Merge pull request #90 from yeojz/readme-patch-1Michel Weststratebefore adoption3e1dcea
lines 172–173why, one step back172The one argument version is intended to be used for currying. This means that you get a pre-bound producer that only needs a state to produce the value from.173The producer function gets passed in the draft, and any further arguments that were passed to the curried function.Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 174–190why, one step back174175For example:176177```javascript178// mapper will be of signature (state, index) => state179const mapper = produce((draft, index) => {180 draft.index = index181})182183// example usage184console.dir([{}, {}, {}].map(mapper))185//[{index: 0}, {index: 1}, {index: 2}])186```187188This mechanism can also nicely be leveraged to further simplify our example reducer:189190```javascriptFixed configurability of array.length on proxies. Fixes #50Michel Weststratebefore adoption1c7df26
lines 191–192why, one step back191import produce from 'immer'192Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 193–195why, one step back193const byId = produce((draft, action) => {194 switch (action.type) {195 case RECEIVE_PRODUCTS:Merge pull request #71 from Keysox/patch-1Michel Weststratebefore adoptiond47db4d
line 196why, one step back196 action.products.forEach(product => {Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 197why, one step back197 draft[product.id] = productMerge pull request #71 from Keysox/patch-1Michel Weststratebefore adoptiond47db4d
line 198why, one step back198 })Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 199–212why, one step back199 })200 }201})202```203204Note that `state` is now factored out (the created reducer will accept a state, and invoke the bound producer with it).205One think to keep in mind; you cannot use this construction to initialize an uninitialized state. E.g. `draft = {}` doesn't do anything useful.206207## Auto freezing208209 Immer automatically freezes any state trees that are modified using `produce`.210 This protects against accidental modifications of the state tree outside of a producer.211 This comes with a performance impact, so it is recommended to disable this option in production.212 It is by default enabled.Disable auto freeze in production, fixes #46, also see #76Michel Weststratebefore adoption71d5909
line 213why, one step back213 By default it is turned on during local development, and turned off in production.Documented 1.0.0 release!Michel Weststratebefore adoption5e16b30
line 214why, one step back214 Use `setAutoFreeze(true / false)` to explicitly turn this feature on or off.Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 215why, one step back215Implemented and document #108: allow returning values from producersMichel Weststratebefore adoptionc589ddd
lines 216–258why, one step back216## Returning data from producers217218It is not needed to return anything from a producer, as Immer will return the (finalized) version of the `draft` anyway.219However, it allowed to just `return draft`.220221It is also allowed to return abritrarily other data from the producer function. But _only_ if you didn't modify the draft.222This can be useful to produce an entirely new state. Some examples:223224```javascript225const userReducer = produce((draft, action) => {226 switch (action.type) {227 case "renameUser":228 // OK: we modify the current state229 draft.users[action.payload.id].name = action.payload.name230 return draft // same as just 'return'231 case "loadUsers":232 // OK: we return an entirely new state233 return action.payload234 case "adduser-1":235 // NOT OK: This doesn't do change the draft nor return a new state!236 // It doesn't modify the draft (it just redeclares it)237 // In fact, this just doesn't do anything at all238 draft = { users: [...draft.users, action.payload]}239 return240 case "adduser-2":241 // NOT OK: modifying draft *and* returning a new state242 draft.userCount += 1243 return { users: [...draft.users, action.payload] }244 case "adduser-3":245 // OK: returning a new state. But, unnecessary complex and expensive246 return {247 userCount: draft.userCount + 1,248 users: [...draft.users, action.payload]249 }250 case "adduser-4":251 // OK: the immer way252 draft.userCount += 1253 draft.push(action.payload)254 return255 }256})257```258Documented 1.0.0 release!Michel Weststratebefore adoption5e16b30
lines 259–283why, one step back259## Using `this`260261The recipe will be always invoked with the `draft` as `this` context.262263This means that the following constructions are also valid:264265```javascript266const base = { counter: 0 }267268const next = produce(base, function() {269 this.counter++270})271console.log(next.counter) // 1272273// OR274const increment = produce(function() {275 this.counter++276})277console.log(increment(base).counter) // 1278```279280## TypeScript or Flow281282The Immer package ships with type definitions inside the package, which should be picked up by TypeScript and Flow out of the box and without further configuration.283Merge pull request #68 from mweststrate/feature/reuseMichel Weststratebefore adoption20394c0
line 284why, one step back284## Immer on older JavaScript environments?Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 285–287why, one step back285286By default `produce` tries to use proxies for optimal performance.287However, on older JavaScript engines `Proxy` is not available.Merge pull request #68 from mweststrate/feature/reuseMichel Weststratebefore adoption20394c0
line 288why, one step back288For example, when running Microsoft Internet Explorer or React Native on Android.Default build includes both Proxy and ES5 implementationMichel Weststratebefore adoptionbd9c47b
line 289why, one step back289In such cases Immer will fallback to an ES5 compatible implementation which works identical, but is a bit slower.Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 290–291why, one step back290291## PitfallsFixed bug, wrote readmeMichel Weststratebefore adoption1b8a694
line 292why, one step back292Implemented and document #108: allow returning values from producersMichel Weststratebefore adoptionc589ddd
line 293why, one step back2931. Don't redefine draft like, `draft = myCoolNewState`. Instead, either modify the `draft` or return a new state. See [Returning data from producers](#returning-data-from-producers).Removed superfluos Redux examples (fixes #57). Explained working with Dates betterMichel Weststratebefore adoptiona7b5df7
lines 294–298why, one step back2941. Currently, Immer only supports plain objects and arrays. PRs are welcome for more language built-in types like `Map` and `Set`.2952. Immer only processes native arrays and plain objects (with a prototype of `null` or `Object`). Any other type of value will be treated verbatim! So if you modify a `Map` or `Buffer` (or whatever complex object from the draft state), the changes will be persisted. But, both in your new and old state! So, in such cases, make sure to always produce fresh instances if you want to keep your state truly immutable.2963. For example, working with `Date` objects is no problem, just make sure you never modify them (by using methods like `setYear` on an existing instance). Instead, always create fresh `Date` instances. Which is probably what you were unconsciously doing already.2974. Since Immer uses proxies, reading huge amounts of data from state comes with an overhead (especially in the ES5 implementation). If this ever becomes an issue (measure before you optimize!), do the current state analysis before entering the producer function or read from the `currentState` rather than the `draftState`2985. Some debuggers (at least Node 6 is known) have trouble debugging when Proxies are in play. Node 8 is known to work correctly.Merge pull request #38 from mweststrate/feature/performanceMichel Weststratebefore adoption670fcff
line 299why, one step back299Added section with cool stuffMichel Weststratebefore adoption69aedd8
lines 300–304why, one step back300## Cool things built with immer301302* [immer based handleActions](https://gist.github.com/kitze/fb65f527803a93fb2803ce79a792fff8) _Boilerplate free actions for Redux_303* [redux-box](https://github.com/anish000kumar/redux-box) _Modular and easy-to-grasp redux based state management, with least boilerplate_304Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 305–306why, one step back305## How does Immer work?306Object.is for equality, more tests. Fixes #43, #42, #48Michel Weststratebefore adoptione29a792
line 307why, one step back307Read the (second part of the) [introduction blog](https://medium.com/@mweststrate/introducing-immer-immutability-the-easy-way-9d73d8f71cb3).Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 308why, one step back308Merge pull request #38 from mweststrate/feature/performanceMichel Weststratebefore adoption670fcff
lines 309–310why, one step back309## Performance310Merge pull request #55 from typicode/patch-1Michel Weststratebefore adoption804703b
line 311why, one step back311Here is a [simple benchmark](__performance_tests__/todo.js) on the performance of Immer.Merge pull request #38 from mweststrate/feature/performanceMichel Weststratebefore adoption670fcff
lines 312–317why, one step back312This test takes 100.000 todo items, and updates 10.000 of them.313_Freeze_ indicates that the state tree has been frozen after producing it. This is a _development_ best practice, as it prevents developers from accidentally modifying the state tree.314315These tests were executed on Node 8.4.0.316Use `yarn test:perf` to reproduce them locally.317Fixed performance imagesMichel Weststratebefore adoption89e0d24
line 318why, one step back318Merge pull request #38 from mweststrate/feature/performanceMichel Weststratebefore adoption670fcff
lines 319–320why, one step back319320Some observations:Documented 1.0.0 release!Michel Weststratebefore adoption5e16b30
line 321why, one step back321* From `immer` perspective, this benchmark is a _worst case_ scenario, because the root collection it has to proxy is really large relatively to the rest of the data set.Merge pull request #38 from mweststrate/feature/performanceMichel Weststratebefore adoption670fcff
line 322why, one step back322* The _mutate_, and _deepclone, mutate_ benchmarks establish a baseline on how expensive changing the data is, without immutability (or structural sharing in the deep clone case).Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
line 323why, one step back323* The _reducer_ and _naive reducer_ are implemented in typical Redux style reducers. The "smart" implementation slices the collection first, and then maps and freezes only the relevant todos. The "naive" implementation just maps over and processes the entire collection.Fixed #49Michel Weststratebefore adoption5227173
line 324why, one step back324* Immer with proxies is roughly speaking twice as slow as a hand written reducer. This is in practice negligible.Merge pull request #38 from mweststrate/feature/performanceMichel Weststratebefore adoption670fcff
line 325why, one step back325* Immer is roughly as fast as ImmutableJS. However, the _immutableJS + toJS_ makes clear the cost that often needs to be paid later; converting the immutableJS objects back to plain objects, to be able to pass them to components, over the network etc... (And there is also the upfront cost of converting data received from e.g. the server to immutable JS)`immer` -> `produce`. Implements #24Michel Weststratebefore adoptione3eacea
line 326why, one step back326* The ES5 implementation of Immer is significantly slower. For most reducers this won't matter, but reducers that process large amounts of data might benefit from not (or only partially) using an Immer producer. Luckily, Immer is fully opt-in.Merge pull request #38 from mweststrate/feature/performanceMichel Weststratebefore adoption670fcff
line 327why, one step back327* The peeks in the _frozen_ versions of _just mutate_, _deepclone_ and _naive reducer_ come from the fact that they recursively freeze the full state tree, while the other test cases only freeze the modified parts of the tree.Added performance measurements, fixes #6Michel Weststratebefore adoption553299f
line 328why, one step back328Added FAQ sectionMichel Weststratebefore adoptionb9b418e
lines 329–356why, one step back329## FAQ330331_(for those who skimmed the above instead of actually reading)_332333**Q: Does Immer use structural sharing? So that my selectors can be memoized and such?**334335A: Yes336337**Q: Does Immer support deep updates?**338339A: Yes340341**Q: I can't rely on Proxies being present on my target environments. Can I use Immer?**342343A: Yes344345**Q: Can I typecheck my data structures when using Immer?**346347A: Yes348349**Q: Can I store `Date` objects, functions etc in my state tree when using Immer?**350351A: Yes352353**Q: Is it fast?**354355A: Yes356Added question about freezingMichel Weststratebefore adoption6ac7707
lines 357–360why, one step back357**Q: Idea! Can Immer freeze the state for me?**358359A: Yes360Added performance measurements, fixes #6Michel Weststratebefore adoption553299f
lines 361–363why, one step back361## Credits362363Special thanks goes to @Mendix, which supports it's employees to experiment completely freely two full days a month, which formed the kick-start for this project.Merge pull request #37 from mweststrate/feature/curryMichel Weststratebefore adoption014019e
lines 364–367why, one step back364365## Donations366367A significant part of my OSS work is unpaid. So [donations](https://mobx.js.org/donate.html) are greatly appreciated :)