When react-redux@8 is installed, type is not normally found in dispatch.
See original GitHub issueWhat version of React, ReactDOM/React Native, Redux, and React Redux are you using?
- React: 17.0.2
- ReactDOM/React Native: 17.0.2 / 0.68.1
- Redux: 4.2.0
- React Redux: 8.0.1
What is the current behavior?
TS2345: Argument of type ‘AsyncThunkAction<TicketEntity[], void, {}>’ is not assignable to parameter of type ‘AnyAction’. Property ‘type’ is missing in type ‘AsyncThunkAction<TicketEntity[], void, {}>’ but required in type ‘AnyAction’.
const dispatch = useDispatch();
...
useEffect(()=>{
dispatch(anyAction()) ; // error
},[dispatch])
### What is the expected behavior?
dispatch type changed before version
// v7
const dispatch: Dispatch
<AsyncThunkAction<ILoadNoticeListReturn, boolean | QueryDocumentSnapshot<INotice> | undefined, {}>>(action: AsyncThunkAction<...>) => AsyncThunkAction<...>
// v8
const dispatch: Dispatch
<AnyAction>(action: AnyAction) => AnyAction
### Which browser and OS are affected by this issue?
_No response_
### Did this work in previous versions of React Redux?
- [X] Yes
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Type errors after upgrading to 1.8.1 and Redux 8 ... - GitHub
Argument of type '(dispatch: AppDispatch) => Promise<void>' is not assignable to parameter of type 'AnyAction'. Property 'type' is missing in type ...
Read more >React 18, React Redux 8, and TypeScript: What you need to ...
Learn about Redux 8, a state management library for React, and how it works with React 18 and it's TypeScript codebase conversion.
Read more >Connect | React Redux
The connect() function connects a React component to a Redux store. It provides its connected component with the pieces of the data it...
Read more >Redux Toolkit - Argument of type 'AsyncThunkAction<>' is not ...
This is my very basic action: export const getAllPages = createAsyncThunk<GETALLPAGESACTION, string, { dispatch: AppDispatch; state ...
Read more >import provider from 'react-redux' error - You.com - You.com
Attempted import error: 'Provider' is not exported from 'react-redux' ... It just calls dispatch normally, it can also use mapDispatchToProps to bind such ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@phryneas oh! Thank you for the reply. Hope you have a nice day 😃
This was actually a bug in the past. since the default
dispatch
type does not take theredux-thunk
middleware into consideration and so always returned a wrong return value from thedispatch
call. In short, it was possible todispatch
anything that was not a valid action.To have redux-thunk’s typings for a store with thunk, you need to set up correctly typed hooks: