Skip to content

Unexpected recalculations of derived stores #37

@anachronzy

Description

@anachronzy

In our nextjs app we get some data on a server and then hydrate it on client via EffectorNext component. Say we have $server store which serializes and sends data to the client. I noticed that if i have some derived store (say, $derived) based on this value via .map() or combine() utilitiy on each navigation i get multiple recalculations of this derived store despite the fact that the docs state that it should only recalculate when upstream store changes. Recalculations are called with the latest value of $server store.

Here are the steps to reproduce:

  1. provide some value via $server store. Derived store calculates correctly
  2. navigate to some other page with no $server value provided. For some reason derived store recalculates.

If I use sample() everything is ok because this derived value gets serialized as well. useStoreMap works well too but with this approach i can't access this derived value in stores.

I reproduced this in playground-app in which there are not so many recalculations but in my production app i get 500+ calls on each not shallow page transition.

Am i doing something wrong and this is expected behavior? I expect combine to not be called at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions