PttRulez
PttRulez

Reputation: 175

How can I trigger RTK Query reuqest if some slice's state has been changed?

I'm using RTK Query in my app. I have some filters on a page. I want to keep them in store so that if I leave page and come back they would stay the same. So when user changes them in select dropdowns app dispatches some reducer's action.
How can I subscribe to those filters changed and make RTK Query after filters have been changed? So it would be subsription to changes of some slice's piece of state, which would trigger rtk query request

Upvotes: 0

Views: 586

Answers (1)

phry
phry

Reputation: 44276

You mean like this?

const filterValueFromStore = useSelector(state => state.foo.bar)
const result = useSomeQuery({ someFilter: filterValueFromStore })

Upvotes: 1

Related Questions