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