Open mfbx9da4 opened 2 years ago
Suppose you have a list of items. Each item has some derived data which you would like to cache so that stays referentially identical to avoid unnecessary re-renders in React. The number of items to cache will depend on the user and will change over time. It's easy to know how big that list is at runtime and therefore trivial to know how big that cache size should be but impossible to have a good default size up front.
@mfbx9da4 This looks to me as a use case that's best served by weak map based configuration.
So the cache is attached to an item, and if that item is disposed, then derived data you cached for it will also be disposed
WeakMap is not available in react native
WeakMap is not available in react native
What do you mean? WeakMap
is a native JavaScript interface and this is a package that requires the JavaScript runtime to be run
Although I haven't tested myself I saw this comment "WeakRef is not supported in Hermes or JSC on Android". I believe them!
@mfbx9da4 memoizee
under the hook doesn't use WeakRef
but WeakMap
, which as I search seems supported by all engines
@mfbx9da4 can you describe the use case?