Reactjs 错误:在处理“@@INIT”操作时,还原程序“auth”返回未定义。若要忽略操作,必须显式返回上一个状态
我想不出我在这件事上做错了什么。只是试着为我的项目实践准备一些基本的细节和故事 Ducks/auth.jsReactjs 错误:在处理“@@INIT”操作时,还原程序“auth”返回未定义。若要忽略操作,必须显式返回上一个状态,reactjs,redux,react-redux,redux-thunk,redux-saga,Reactjs,Redux,React Redux,Redux Thunk,Redux Saga,我想不出我在这件事上做错了什么。只是试着为我的项目实践准备一些基本的细节和故事 Ducks/auth.js const action = name => `/auth/${name}`; export const FETCH = action('FETCH'); export const fetchUser = (user) => ({ type: FETCH, user }); const auth = (state = null, action) => {
const action = name => `/auth/${name}`;
export const FETCH = action('FETCH');
export const fetchUser = (user) => ({ type: FETCH, user });
const auth = (state = null, action) => {
switch (action.type) {
default:
return console.log('Hello World');
}
};
export default auth;
Sagas/auth.js
import {
fork,
takeLatest,
} from 'redux-saga/effects';
import * as actions from 'ducks/auth';
export function* fetchUser() {
yield console.log('Hello World');
}
export function* watchFetchUser() {
yield takeLatest(actions.FETCH, fetchUser);
}
export default function* rootSaga() {
yield [
fork(watchFetchUser)
];
}
有人能解决此错误吗?在默认情况下,您需要返回状态:
const auth = (state = null, action) => {
switch (action.type) {
default:
console.log('Hello World')
return state;
}
};