Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Getting type error in redux in react native with typescript

$
0
0

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.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>