I have an application where multiple components are fetching data like below and is using the data for some rendering.
const {data} = useGetUserQuery({shippingAddressId: 123});
I'm trying to figure out what is the normal RTK query pattern if I wanted to call useGetUserQuery with a new shippingAddressId and have all the components consuming this hook rerender?
Since RTK Query uses the query parameters as cache keys, the data doesn't update since the shippingAddressId is hardcoded.
I'm currently getting around this by dispatching an action to the redux store which updates a params object with say shippingAddressId and using that as my query argument in the useGetUserQuery({...params}) hook.
By dispatching an action, all my components that are consuming the useGetUserQuery hook gets updated.
Is this an anti-pattern?
Thank you and I look forward to any recommendations.