Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!