I am trying to store the boolean value of is phone number verified or not.
In my login component:
await dispatch(setOTPVerified(data.is_phone_verified));
Action.tsx:
export const OTP_VERIFIED = 'OTP_VERIFIED';export const setOTPVerified = (OTPVerified: boolean) => { return { type: OTP_VERIFIED, OTPVerified, };};
Reducer.tsx:
export interface ExtrasParams { OTPVerified?: any;}const initialData: ExtrasParams = { OTPVerified: false, };const extrasReducer = (state = initialData, action: any): ExtrasParams => { switch (action.type) { case OTP_VERIFIED: state = {...state, OTPVerified: action.OTPVerified}; return state; default: return state; } };
Saga.tsx:
function* getOTPVerified(action: any) { yield put({ OTPVerified: action.OTPVerified, });}export default function* extrasSaga() { yield takeLatest(OTP_VERIFIED, getOTPVerified);}
Error in console:
Error: Actions may not have an undefined "type" property. Have you misspelled a constant?The above error occurred in task getOTPVerified created by takeLatest(OTP_VERIFIED, getOTPVerified)
I am new to using typescript in react native, and not very clear with declaring types in redux. I have been trying different types, but I am not able to clear this error.