You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue occurs because the middleware needs the RootState type, but that type isn't defined and available until the store is created, and the store needs the middleware in order to do that.
What docs page needs to be fixed?
What is the problem?
When using TypeScript with RTK and adding types to a custom middleware following from https://redux.js.org/usage/usage-with-typescript#type-checking-middleware, for example:
And setting the
RootState
type following https://redux.js.org/usage/usage-with-typescript#define-root-state-and-dispatch-types, i.e.:Then the following circular type reference error is thrown:
This issue occurs because the middleware needs the
RootState
type, but that type isn't defined and available until the store is created, and the store needs the middleware in order to do that.What should be changed to fix the problem?
Per @markerikson on Reactiflux Discord, this can be fixed by switching the definition of
RootState
to be:This information should be noted under the Type Checking Middleware section.
The text was updated successfully, but these errors were encountered: