Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

fix: React-Hot-Loader compatibility #522

Merged
merged 1 commit into from
Aug 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@ let warnedAboutObserverInjectDeprecation = false
export const componentByNodeRegistry = typeof WeakMap !== "undefined" ? new WeakMap() : undefined
export const renderReporter = new EventEmitter()

function createSymbol(name) {
const createdSymbols = {}

function createRealSymbol(name) {
if (typeof Symbol === "function") {
return Symbol(name)
}
return `$mobxReactProp$${name}${Math.random()}`
}

function createSymbol(name) {
if (!createdSymbols[name]) {
createdSymbols[name] = createRealSymbol(name)
}
return createdSymbols[name]
}

const skipRenderKey = createSymbol("skipRender")
const isForcingUpdateKey = createSymbol("isForcingUpdate")

Expand Down