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

220
Vistas
Defining type to history.push() which has been passed as a payload to the saga using typescript?

I have used { useHistory } from react-router-dom in the react component. And on button click am try to pass the history instance as a payload to the saga through action.ts

component.tsx

import React from 'react';
import { useDispatch } from 'react-redux';
import { useHistory } from 'react-router-dom';
import {recievingHistoryAsPayload } from 'store/actions';


const Component: React.FC = () => {
  const history = useHistory();
  const dispatch = useDispatch();

  const sendHistoryObj = () => {
   dispatch(recievingHistoryAsPayload({ payload: history }));
 };
 return (
  <Button
      onClick={sendHistoryObj}
  />
 );
};

export default Component;

action.ts

export const recievingHistoryAsPayload = createAction(
 Types.RECEIVING_HISTORY_AS_PAYLOAD,
 (data) => data
);

saga.ts

export function* recievingHistoryAsPayloadSaga(action: any): Generator {
  yield call(action?.payload?.push, '/');
}

in saga.ts, for action payload eslint is throwing a warring with message Argument 'action' should be typed with a non-any type.

What should be type defined for action in saga.ts

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