score:1

here is an example of your reducer with explicit types:

interface iarticles {
  articles: string[];
}

const initialstate: iarticles = {
  articles: []
};

export interface useraction {
  type: string;
  payload: string;
}

const rootreducer = (state = initialstate, action: useraction): iarticles => {
  switch (action.type) {
    case "add_article": {
      return {
        articles: [action.payload, ...state.articles]
      };
    }
    default:
      return state;
  }
};

previously i have expirienced same issue as you are, because types in reducer being wrong.


Related Query

More Query from same tag