adrien
adrien
SSolidJS
Created by adrien on 12/6/2023 in #support
Lazy-initialized createMemo's updating once, but not again
I'm trying to debug this createMemo issue I'm running into. What I'm really trying to get at is a nested memoized object, but given that something like that doesn't appear to exist in the API as is, this is how I'm doing it. I threw together some sample code (I'll leave it as the next comment) to show a minimal example of the issue I'm running into. When you click either of the counter buttons, the count increments, and the fibonacci memoized value for that counter updates. But then any subsequent increment, the fibonacci value does not update. So it appears that the memoized computation performs properly for the initial state, and for the 2nd state (which implies that the dependencies are being inferred properly). But then it just stops working after that. In the real-world thing I'm working on that inspired this sample, there could be thousands of items (counters in this example), and only one might be looked at at a time. So I'd like for the memoized computation to be lazily initialized when needed (so that 1000 computations aren't kicked off when they're not needed), and for the memoized computation to be remembered if the view changes to another "counter", and then back to a previous one, and so that the memoized result can be shared between different views that have access to the memoized computation. Would love to understand why I'm seeing this odd behavior of the memoized computation working for the first 2 states, but then not after that. Thanks!
29 replies
SSolidJS
Created by adrien on 2/21/2023 in #support
How to untrack() or on() a props value?
Maybe I'm thinking about this the wrong way? But I'm wondering how to untrack() a props value the way you'd untrack() a signal in a createEffect for example. Since the reactive values in props are wrapped in a getter, it seems impossible to get the Accessor that can be used in untrack() or on(). I suppose I could derive a new Accessor with something like:
const thing = () => props.thing;
const thing = () => props.thing;
then untrack(thing) ? But that seems like a roundabout way of doing it, would that even make sense? Thanks!
16 replies