Help migrating from RTK thunk/reducer to RTKQ #4501
-
Hello I have a slice with a thunk that makes an api call to get some data. I also have a reducer in that same slice that is called in some places in the app to change data in the slice without making an api call. I am just wondering what the best way of migrating this code is. Maybe is there a way to change data in the api area of the store with reducers or something else or is that a no go? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The general approach would be to:
See the examples here: Note that you can do manual cache updates if needed: |
Beta Was this translation helpful? Give feedback.
The general approach would be to:
useSelector
+useEffect
call you have that triggers the current request with the new RTKQ query hook for that endpointSee the examples here:
Note that you can do manual cache updates if needed: