Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
1234567891011121314151617181920212223242526272829303132333435
  1. # @emotion/weak-memoize
  2. > A memoization function that uses a WeakMap
  3. ## Install
  4. ```bash
  5. yarn add @emotion/weak-memoize
  6. ```
  7. ## Usage
  8. 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.
  9. ```jsx
  10. import weakMemoize from '@emotion/weak-memoize'
  11. let doThing = weakMemoize(({ someProperty }) => {
  12. return { newName: someProperty }
  13. })
  14. let obj = { someProperty: true }
  15. let firstResult = doThing(obj)
  16. let secondResult = doThing(obj)
  17. firstResult === secondResult // true
  18. let newObj = { someProperty: true }
  19. let thirdResult = doThing(newObj)
  20. thirdResult === firstResult // false
  21. ```