无法弄清楚我在这方面出了什么问题。只是尝试为我的项目实践设置基本的鸭子和传奇。
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) => {
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)
];
}
任何人都可以解决此错误吗?
答案 0 :(得分:1)
您需要在默认情况下返回状态:
const auth = (state = null, action) => {
switch (action.type) {
default:
console.log('Hello World')
return state;
}
};