reactjs - Unable to call Curried function from componentDidMount() in React component -
i have following function in action
export const fetchdevicedata = (devicedata: object): thunkaction => (dispatch: dispatch, getstate: getstate, axios: any) => { console.log('inside fetchdevicedata', devicedata); return dispatch(fetchdevicedataapi(axios, url, devicedata)); }; and call in following way in componentdidmount() block in component
// type declaration (imported separate file) export type devicereg = { [devicedata: object]: { readystatus: string, err: any, payload: object, } }; // prop type declaration type props = { device_reg: deviceregtype, fetchdevicedata: () => void, } componentdidmount() { const x = this.getdevicedata(); console.log('header mount mobile', x); action.fetchdevicedata(x); } // connector const connector: connector<{}, props> = connect( ({ device_reg }: reducer) => ({ device_reg }), (dispatch: dispatch) => ({ fetchdevicedata: (devicedata) => dispatch(action.fetchdevicedata(devicedata)), }), ); export default header; the issue the, fetchdevicedata(x) function not getting called when include parameters dispatch: dispatch, getstate: getstate, axios: any in function, works other wise. imports , dependencies not issue have verified them loads of times.
any suggestions, hints or solutions of great help. please let me know if need kind of clarification or context regarding issue.
thanks in advance.
can try removing axios: any dispatch: dispatch, getstate: getstate, axios: any ?
i think there's supposed dispatch , getstate, because that's gets injected redux-thunk.
Comments
Post a Comment