• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

437
Views
Dispatching action in thunk results in error: can't get state of undefined

Here is the action itself:

import actionFromAnotherReducer from '../subfolder/reducer'

export const asyncAction = createAsyncThunk(
  'reducerName/actionName',
  async(
    data,
    { dispatch, getState }
  ) => {
    return somePromise.then(response => {
      dispatch(actionFromAnotherReducer(response))
    })
  }
)

And here is where I get this error Cannot read properties of undefined (reading 'getState'): The above error occurred in the <Provider> component. The thing is when I remove the dispatch(action), everything works, and also if I dispatch an action from the same folder reducer, it works as well. How to fix it?

about 3 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error