Skip to content
Myr

feat: Dropped node 6 support

Before adoption: this commit came in with the history the project adopted, so no landing records it.

BREAKING CHANGE

authored by Michel Weststrate · committed by Alec Larson · parent 17d69c3 · Browse files · 3 files+3 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+3 added−7 removed

  • tests:+3 added−5 removed
  • other:+0 added−2 removed

3 files+3 added−7 removed

modified:__tests__/base.js+3 added-5 removed
890 unmodified lines
891 }).toThrowErrorMatchingSnapshot()892 })893 })894895 // TODO: rewrite tests with async/await once node 6 support is dropped895 describe("async recipe function", () => {896 it("can modify the draft", () => {897 const base = {a: 0, b: 0}899 return produce(base, d => {898 return produce(base, async d => {899 d.a = 1901 return Promise.resolve().then(() => {902 d.b = 1903 })900 await Promise.resolve()901 d.b = 1902 }).then(res => {903 expect(res).not.toBe(base)904 expect(res).toEqual({a: 1, b: 1})905 })
362 unmodified lines
modified:.travis.yml-1 removed
modified:readme.md-1 removed
661 unmodified lines
6626631. 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).6641. Immer assumes your state to be a unidirectional tree. That is, no object should appear twice in the tree, and there should be no circular references.6651. 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`. Also, realize that immer is opt-in everywhere, so it is perfectly fine to manually write super performance critical reducers, and use immer for all the normal ones. Also note that `original` can be used to get the original state of an object, which is cheaper to read.6661. Some debuggers (at least Node 6 is known) have trouble debugging when Proxies are in play. Node 8 is known to work correctly.6661. Always try to pull `produce` 'up', for example `for (let x of y) produce(base, d => d.push(x))` is exponentially slower than `produce(base, d => { for (let x of y) d.push(x)})`6671. It is possible to return values from producers, except, it is not possible to return `undefined` that way, as it is indistinguishable from not updating the draft at all! If you want to replace the draft with `undefined`, just return `nothing` from the producer.668669## Cool things built with immer
138 unmodified lines