cityReducer.ts 566 Bytes
Newer Older
mayi's avatar
mayi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
import {CHANGE_INPUT} from './cityActions'
export interface CityState {
    cityInput:string | number
  cityName: string;
  cityLists: { name: string }[];
}
const defaultState: CityState = {
    cityInput:'',
  cityName: "东京",
  cityLists: [
    {
      name: "东京",
    },
  ],
};

 export default (state = defaultState, action) => {
  switch (action.type) {
    case CHANGE_LANGUAGE:
      i18n.changeLanguage(action.payload); //此处会导致不是纯函数
      return { ...state, language: action.payload };
  
    default:
      return state;
  }
 };