diff --git a/src/utils/memoize.js b/src/utils/memoize.js index 059cc4e0f..47f1f63bd 100644 --- a/src/utils/memoize.js +++ b/src/utils/memoize.js @@ -11,6 +11,13 @@ import { Map } from 'immutable' const LEAF = {} +/** + * An unique value used to detect cache misses + * + * @type {Object} + */ +const NO_SET = {} + /** * Memoize all of the `properties` on a `object`. * @@ -31,7 +38,10 @@ function memoize(object, properties) { const keys = [property, ...args, LEAF] const cache = this.__cache = this.__cache || new Map() - if (cache.hasIn(keys)) return cache.getIn(keys) + const cachedValue = cache.getIn(keys, NO_SET) + if (cachedValue !== NO_SET) { + return cachedValue + } const value = original.apply(this, args) this.__cache = cache.setIn(keys, value)