Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

279
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda