Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTQ: How to unsubscribe from a useLazyQuery #2055

Closed
nichita-pasecinic opened this issue Feb 21, 2022 · 5 comments
Closed

RTQ: How to unsubscribe from a useLazyQuery #2055

nichita-pasecinic opened this issue Feb 21, 2022 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers rtk-query

Comments

@nichita-pasecinic
Copy link
Contributor

nichita-pasecinic commented Feb 21, 2022

Hello 👋

In documentation https://redux-toolkit.js.org/rtk-query/usage/usage-without-react-hooks#removing-a-subscription
is specified a different way of subscription - un-subscription method for a query, but how to we do it with a hook ?

const [trigger, { data }] = useLazyEnpointQuery();

I cant pass a skip property to useLazyQuery that forces the unsubscription from the query, it can be used only with the useQuery hook. So how can I unsubscribe from a lazy query ?

Thanks for help!

@nichita-pasecinic
Copy link
Contributor Author

Hi,
Any updates on it? wouldn't be nice if the useLazyEndpointQuery() returned something like unsubscribe here :

const [trigger, { data, unsubscribe }] = useLazyEnpointQuery();

@phryneas phryneas added enhancement New feature or request good first issue Good for newcomers labels Mar 16, 2022
@phryneas
Copy link
Member

At the moment, the only way to unsubscribe from a lazy query is to start a new one with a different argument or to unmount the component.

It might be a nice to have to have an unsubscribe option, but it's not high in the priorities. PRs against useLazyQuerySubscription are welcome.

@bleedingAyush
Copy link

bleedingAyush commented Aug 18, 2022

I think the feature is added.
rtk useLazyQuery()

@henkkasoft
Copy link

I think the reset would be more important like @phryneas mentions here #2133 (comment)

I hope this reset feature will gain priority

@markerikson
Copy link
Collaborator

Out in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.4.0 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers rtk-query
Projects
None yet
Development

No branches or pull requests

5 participants