Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

280
Vistas
Hoisting error using error handler in redux saga with React 17.0.2

Im using an error handler wrapper in redux-saga, this is in helpers folder

src/helpers/index.ts

import { call, put } from "redux-saga/effects";
import { authActions } from "src/store";
import { snackbarActions } from "src/store/snackbar/actions";
import { cookies } from ".";

/*  SAFE SAGA CALL FOR ERROR HANDLING */
export function sagaWrapper(sagaFn: any, errorAction?: any) {
   return function* (): any {
       try {

           return yield call(sagaFn, arguments[0]);

       } catch (error: any) {
           console.log("Error:", error)
       }
   }
}

Then I use it in a saga

src/store/persons/saga.ts

import { sagaWrapper } from "src/helpers";
import { call, put, takeLatest } from "redux-saga/effects";
import { Service } from "src/services";
import { ActionType, ResponseType } from "src/types";
import { personActions } from "./actions";
import { PERSON_TYPES } from "./types";

const personService = new Service('persons');

function* search({ payload }: ActionType) {
    const response: ResponseType = yield call(personService.patchPath, 'search', payload.person);
    yield put(personActions.setSearch(response.data));
}

export function* personSagas() {
    yield takeLatest(PERSON_TYPES.SEARCH, sagaWrapper(search, personActions.setSearch()))
}

After that, I use rootSaga and set the middleware in redux store. When I run the development server I get this error:

io-6de156f3.js:111 TypeError: Cannot read properties of undefined (reading 'sagaWrapper')
    at Module.sagaWrapper (useQueryParams.ts:12:1)
    at personSagas (sagas.ts:16:1)
    at personSagas.next (<anonymous>)
    at next (redux-saga-core.esm.js:1157:1)
    at proc (redux-saga-core.esm.js:1108:1)
    at runEffect (redux-saga-core.esm.js:1199:1)
    at digestEffect (redux-saga-core.esm.js:1271:1)
    at redux-saga-core.esm.js:673:1
    at Array.forEach (<anonymous>)
    at runAllEffect (redux-saga-core.esm.js:672:1)

io-6de156f3.js:112 The above error occurred in task rootSaga
    created by rootSaga

Im using create-react-app with react 17.0.2 version, in the past I created a react app with version 17.0.0 and everything was working perfectly. Any solution?

Thanks.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda