AbiirSkincare/React/node_modules/@emotion/weak-memoize
Ravi Gulhane 98f803ffe4 first commit 2026-06-03 10:55:54 +05:30
..
dist first commit 2026-06-03 10:55:54 +05:30
src first commit 2026-06-03 10:55:54 +05:30
LICENSE first commit 2026-06-03 10:55:54 +05:30
README.md first commit 2026-06-03 10:55:54 +05:30
package.json first commit 2026-06-03 10:55:54 +05:30

README.md

@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 = weakMemoize(({ someProperty }) => {
  return { newName: someProperty }
})

let obj = { someProperty: true }

let firstResult = doThing(obj)

let secondResult = doThing(obj)

firstResult === secondResult // true

let newObj = { someProperty: true }

let thirdResult = doThing(newObj)

thirdResult === firstResult // false