Problem with CRA code and the query middleware?
Closed this issue · 1 comments
In order to iron out some issues, I recreated the hacker-news sample in typescript.
https://github.com/TheCarlR/redux-query/tree/feature/hacker-news
It's based on the yarn create react-app my-app --template redux-typescript
CRA template from redux.
I kept the original sample code and added the hacker-news, so that the store would be more real life like.
When I run it, the original code works, with the exception of the async action that now fails.
If I comment out the middleware: [queryMiddleware(superagentInterface, getQueries, getEntities)],
line in store.ts it works again. (Obviously the news isn't loaded.)
The error is Error: Actions must be plain objects. Use custom middleware for async actions.
The action that breaks is a thunk, and is from the redux boiler plate, so I think it should be implemented correctly.
Do you have any idea why this is happening?
Fixed by changing syntax to middleware: getDefaultMiddleware => getDefaultMiddleware().concat(queryMiddleware(superagentInterface, getQueries, getEntities)),
This prevents the default middleware from being replaced.