Skip to content
Myr

Possible solution to #100

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

authored by Michel Weststrate · committed by Michel Weststrate · parent c4a08c7 · Browse files · 2 files+13 added−1 removed
This commit

State

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

Diff stats

2 files+13 added−1 removed

  • other:+13 added−1 removed

2 files+13 added−1 removed

modified:src/es5.js+7 added-1 removed
97 unmodified lines
9899function assertUnfinished(state) {100 if (state.finished === true)101 throw new Error(102 "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process?"102 "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " +103 JSON.stringify(state.copy || state.base)104 )105}106107// this sounds very expensive, but actually it is not that extensive in practice
36 unmodified lines
144 return false145}146147export function produceEs5(baseState, producer) {148 if (isProxy(baseState)) {149 // See #100, don't nest producers150 const returnValue = producer.call(baseState, baseState)151 return returnValue === undefined ? baseState : returnValue152 }153 const prevStates = states154 states = []155 try {156 // create proxy for root
60 unmodified lines
modified:src/proxy.js+6 added