Skip to content

Commit

Permalink
fix: share internal symbols between immer installations
Browse files Browse the repository at this point in the history
The `nothing` symbol is still not portable across installations, since it never escapes any producer that returns it. The only reason this could be an issue is if an Immer-using library transparently wraps a user's function and asks them to install their own copy of Immer if they want to return `nothing` (in that case, the library should instead re-export `nothing` for its users).

Fixes #322
  • Loading branch information
aleclarson committed Mar 5, 2019
1 parent fad74d3 commit 02fed2c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common.js
Expand Up @@ -5,11 +5,11 @@ export const NOTHING =

export const DRAFTABLE =
typeof Symbol !== "undefined"
? Symbol("immer-draftable")
? Symbol.for("immer-draftable")
: "__$immer_draftable"

export const DRAFT_STATE =
typeof Symbol !== "undefined" ? Symbol("immer-state") : "__$immer_state"
typeof Symbol !== "undefined" ? Symbol.for("immer-state") : "__$immer_state"

export function isDraft(value) {
return !!value && !!value[DRAFT_STATE]
Expand Down

0 comments on commit 02fed2c

Please sign in to comment.