使用react+redux 登錄成功后用戶信息存在redux中,用axios封裝一個(gè)請(qǐng)求http.js,以后每次請(qǐng)求都帶自動(dòng)帶上登錄成功的token, 如下:import store from '@/redux/store';export const get = (obj) => {let token = store.getState().userRe.token || '';axios({ ...obj, method: 'get', url: obj.url, params: {token},}).then(() => mull).catch(() => null)}我在react-native上這樣使用是沒問題的,但是在react中,http.js引入store則會(huì)以下錯(cuò)誤.Error: Reducer "userRe" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.
redux使用問題
慕妹3146593
2018-12-20 18:15:21