I am currently working on implementing a feature to store the boolean value of whether a phone number is verified or not.
Within 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 with react native and still learning about declaring types in redux. I have tried different approaches but am struggling to resolve this error.