Closed lxsmnsyc closed 1 year ago
- React frees up
useMemo
references in a scheduled way (think of LRU).useRef
doesn't have this kind of behavior
IMHO forgetti
should keep using useMemo
to optimize the memory usage (which is really important as we are caching basically everything), while skipping the useRef
transformation to keep the behavior correct.
IMHO forgetti should keep using useMemo to optimize the memory usage (which is really important as we are caching basically everything), while skipping the useRef transformation to keep the behavior correct.
No I can't do that, because if it was temporary then that impacts the use of ref
transformations. It has to be persistent at all times.
No I can't do that, because if it was temporary then that impacts the use of
ref
transformations. It has to be persistent at all times.
What I means that, why not leave useRef
usages alone and do not transform useRef
at all. This will keep the behavior correct, while the rest of the caches can benefit from useMemo's auto gc. Since we are cacheing almost everything, it is important to optimize the memory consumption.
Since we are cacheing almost everything, it is important to optimize the memory consumption.
Exactly. The compiled version of useRef
is actually cheaper than the one's in React. I can't revert this behavior anymore because useRef is no longer bounded by hook rules
@lxsmnsyc Can you release an alpha
version of 0.6.0
(e.g. 0.6.0-alpha.1
) so I can try this out in some of my hobby projects, and discover some edge cases?
@lxsmnsyc Can you release an
alpha
version of0.6.0
(e.g.0.6.0-alpha.1
) so I can try this out in some of my hobby projects, and discover some edge cases?
Released 0.6.0-alpha.0
Released
0.6.0-alpha.0
Just found an issue, opened https://github.com/lxsmnsyc/forgetti/issues/25.
useRef
instead ofuseMemo
https://github.com/lxsmnsyc/forgetti/commit/e288b040b2c1580a3827c8680b1563472fa20455useMemo
references in a scheduled way (think of LRU).useRef
doesn't have this kind of behavioroptimizeJSX
config https://github.com/lxsmnsyc/forgetti/pull/23/commits/27093b79fe00703685d811b8a8c60662427c18c8