Home > Mobile >  Why? Argument of type 'AsyncThunkAction<any, void, {}>' is not assignable to paramet
Why? Argument of type 'AsyncThunkAction<any, void, {}>' is not assignable to paramet

Time:05-09

I got this error, found no relevant answer in SO

Argument of type 'AsyncThunkAction<any, void, {}>' is not assignable to parameter of type 'AnyAction'.

<MenuItem
    onClick={() => {
        dispatch(logout()) // <<--HERE
    }}
/>
// slices/tikexAPI.ts
export const logout = createAsyncThunk(`${namespace}/logout`, async () => {
    const { data } = await axios({
        method: 'post',
        url: 'logout',
        headers: { crossDomain: true },
    })
    return data
})

const tikexAPI = createSlice({
    name: 'authnUser',
    initialState,
    reducers: {
        setAuthnRes(state, action: PayloadAction<AuthnRes | null>) {
            state.resp = action.payload
        },
    },
    extraReducers: (builder) => {
        builder
            .addCase(logout.fulfilled, (state, { payload }) => {
                state.authnRes = null
            })
//store.ts

import { configureStore, createSelector } from '@reduxjs/toolkit'
import tikexAPI from './tikexModule/slices/tikexAPI'

export const store = configureStore({
    reducer: { tikexAPI: tikexAPI },
})

I have only two Redux package, reinstalled them, did not help.

// package.json

{
    "dependencies": {
        "@reduxjs/toolkit": "^1.8.1",
        "react-redux": "^8.0.1",

Following this tutorial, it works for me, strange: https://www.youtube.com/watch?v=xtD4YMKWI7w

kukodajanos@Kukoda-MacBook-Pro-2 Team % yarn why redux
yarn why v1.22.18
[1/4]            
  • Related