redux-toolkit
redux-toolkit copied to clipboard
RTQ: How to unsubscribe from a `useLazyQuery`
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!
Hi,
Any updates on it? wouldn't be nice if the useLazyEndpointQuery() returned something like unsubscribe here :
const [trigger, { data, unsubscribe }] = useLazyEnpointQuery();
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.
I think the feature is added. rtk useLazyQuery()
I think the reset would be more important like @phryneas mentions here https://github.com/reduxjs/redux-toolkit/pull/2133#issuecomment-1173164762
I hope this reset feature will gain priority