Skip to content

[Bug] options is not reactive sometimes #64

@ylc395

Description

@ylc395

Very simliar to #10

My app breaks since mobx-tanstack-query@6.1.0. You can reproduce bug by:

const isEnabled = observable.box(false);
let query;

runInAction(() => {
    query = createQuery(() => Promise.resolve({ status: 'success' }), {
        enableOnDemand: true,
        options: () => ({
            enabled: isEnabled.get();
        })
    });

    isEnabled.set(true);
});


query.result.data; // this won't trigger fetching, which is unexpected

The reason is maybe related to action, which defer the calculation of initial value.

reaction(getAllDynamicOptions, this.update, {

How about add a fireImmediately to this reaction?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions