@emotion/weak-memoize
A memoization function that uses a WeakMap
Install
yarn add @emotion/weak-memoize
Usage
Because @emotion/weak-memoize uses a WeakMap the argument must be a non primitive type, e.g. objects, functions, arrays and etc. The function passed to weakMemoize
must also only accept a single argument.
import weakMemoize from '@emotion/weak-memoize' let doThing = let obj = someProperty: true let firstResult = let secondResult = firstResult === secondResult // true let newObj = someProperty: true let thirdResult = thirdResult === firstResult // false