dai-shi/proxy-memoize

Nested calls doesn't work as expected...

groyee opened this issue · 2 comments

Not sure if this is a bug or expected behavior:

I have the following selectors:

export const GetSelectorA = memoize(({ state, props }: { state: RootState; props: any }) => {
   return getSelectorA({
        itemA: state.itemA,
        itemB: GetSelectorB({state, props})
    });
}

// This selector doesn't have direct use of state.itemA
export const GetSelectorB = memoize(({ state, props }: { state: RootState; props: any }) => {
   return getSelectorB({
        itemC: GetSelectorC({state, props})
    });
}

// This selector depends on state.itemA
export const GetSelectorC = memoize(({ state, props }: { state: RootState; props: any }) => {
   return getSelectorC({
        itemA: state.itemA,
    });
}

When state.itemA is changed, GetSelectorA is being called which is good. But it doesn't call GetSelectorB (It takes the memoized version) because I guess GetSelectorB doesn't have direct use of state.itemA? But GetSelectorB depends on GetSelectorC which should be updated when state.itemA is changed...

Is it a bug or am I missing something here?

Hi, I just opened #62, which has the test.
It's currently passing. Can you make it to fail?

I tried to make it fail but I couldn't. I went back to my code to find the difference with the test you wrote and I realized that the problem is on my side. My live reload wasn't working properly and the changes I was making didn't take affect.

Apologies for that. My bad. I will close this issue.